Code : Tout sélectionner
;- Window Constants
Enumeration
#Window_0
#Window_1
EndEnumeration
;- Gadget Constants
Enumeration
#Frame3D_0
#Frame3D_1
#Frame3D_2
#Frame3D_3
#Text_0
#Text_1
#Text_2
#Text_3
#String_0
#String_1
#String_2
#String_3
#Combo_0
#Button_0
#Button_1
#StatusBar_0
EndEnumeration
Procedure Open_Window_1()
Global FontID1
FontID1 = LoadFont(1, "Comic Sans MS", 12, #PB_Font_Bold)
Global FontID2
FontID2 = LoadFont(2, "Comic Sans MS", 50, #PB_Font_Bold)
If OpenWindow(1, 280, 181, 439, 200, "signature", #PB_Window_BorderLess | #PB_Window_ScreenCentered)
SetWindowColor(1, RGB(0, 0, 0))
TextGadget(0, 5, 5, 155, 30, "Programmer par ...")
SetGadgetColor(0, #PB_Gadget_FrontColor, RGB(255, 0, 0))
SetGadgetColor(0, #PB_Gadget_BackColor, RGB(0, 0, 0))
SetGadgetFont(0, FontID1)
TextGadget(1, 110, 50, 195, 95, "venom")
SetGadgetColor(1, #PB_Gadget_FrontColor, RGB(255, 0, 0))
SetGadgetColor(1, #PB_Gadget_BackColor, RGB(0, 0, 0))
SetGadgetFont(1, FontID2)
TextGadget(2, 345, 175, 80, 30, " purebasic")
SetGadgetColor(2, #PB_Gadget_FrontColor, RGB(255, 0, 0))
SetGadgetColor(2, #PB_Gadget_BackColor, RGB(0, 0, 0))
SetGadgetFont(2, FontID1)
Delay(1100)
EndIf
EndProcedure
InitNetwork()
If OpenWindow(#Window_0, 0, 0, 600, 365, "VMail", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Frame3DGadget(#Frame3D_0, 10, 10, 580, 260, "")
Frame3DGadget(#Frame3D_1, 10, 285, 175, 50, "votre fournisseur")
Frame3DGadget(#Frame3D_2, 415, 285, 175, 50, "Envoyer")
Frame3DGadget(#Frame3D_3, 210, 285, 175, 50, "Pièce jointe")
TextGadget(#Text_0, 20, 35, 25, 20, "De:")
TextGadget(#Text_1, 20, 65, 20, 20, "A:")
TextGadget(#Text_2, 15, 95, 30, 20, "Objet:")
StringGadget(#String_0, 50, 30, 530, 20, "")
StringGadget(#String_1, 50, 60, 530, 20, "")
StringGadget(#String_2, 50, 90, 530, 20, "")
EditorGadget(#String_3, 20, 120, 560, 140)
ComboBoxGadget(#Combo_0, 20, 305, 155, 20)
AddGadgetItem(#Combo_0, 0, "alice", 0)
AddGadgetItem(#Combo_0, 1, "caramail", 0)
AddGadgetItem(#Combo_0, 2, "cegetel", 0)
AddGadgetItem(#Combo_0, 3, "club-internet", 0)
AddGadgetItem(#Combo_0, 4, "free", 0)
AddGadgetItem(#Combo_0, 5, "neuf", 0)
AddGadgetItem(#Combo_0, 6, "noos", 0)
AddGadgetItem(#Combo_0, 7, "orange", 0)
AddGadgetItem(#Combo_0, 8, "tele2", 0)
AddGadgetItem(#Combo_0, 9, "tiscali", 0)
AddGadgetItem(#Combo_0, 10, "wanadoo", 0)
SetGadgetState(#Combo_0, 4)
ButtonGadget(#Button_0, 425, 305, 155, 20, "Envoyer")
ButtonGadget(#Button_1, 220, 305, 155, 20, "Ajouté un fichier")
If CreateStatusBar(#StatusBar_0, WindowID(#Window_0))
AddStatusBarField(300)
AddStatusBarField(300)
StatusBarText(#StatusBar_0, 0, "Pas de pièce jointe", #PB_StatusBar_BorderLess)
StatusBarText(#StatusBar_0, 1, "", #PB_StatusBar_BorderLess)
EndIf
EndIf
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
Select EventGadget()
Case #Button_1
piecejointes$ = OpenFileRequester("Choisir un fichier a envoyer", "", "Fichiers|*.*", 0)
testpiecejointes = SelectedFilePattern()
If testpiecejointes = 0
DisableGadget(#Button_1, 1)
StatusBarText(#StatusBar_0, 0, "pièce jointe : " + GetFilePart(piecejointes$), #PB_StatusBar_BorderLess)
ElseIf testpiecejointes = -1
DisableGadget(#Button_1, 0)
EndIf
Case #Button_0
fournisseur$ = GetGadgetItemText(#Combo_0, GetGadgetState(#Combo_0), 0) ; on renvoie le fournisseur
mailserver.s = "smtp." + fournisseur$ + ".fr"
If CreateMail(0, GetGadgetText(#String_0), GetGadgetText(#String_2))
SetMailBody(0, GetGadgetText(#String_3))
AddMailRecipient(0, GetGadgetText(#String_1), #PB_Mail_To)
AddMailAttachment(0, GetFilePart(piecejointes$), piecejointes$, MimeType$)
StatusBarText(#StatusBar_0, 1, "Patientez envoie en cours ...", #PB_StatusBar_BorderLess | #PB_StatusBar_Right)
Resultat = SendMail(0, mailserver.s, 25, 0)
If Resultat = 1
StatusBarText(#StatusBar_0, 1, "", #PB_StatusBar_BorderLess | #PB_StatusBar_Right)
MessageRequester("Information", "Mail envoyé avec succée", 0)
Open_Window_1()
End
ElseIf Resultat = 0
StatusBarText(#StatusBar_0, 1, "Erreur d'envoie ...", #PB_StatusBar_BorderLess | #PB_StatusBar_Right)
MessageRequester("Information", "Le mail n'a pas pu étre envoyé", 0)
EndIf
EndIf
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
Open_Window_1()
si j'utilise un autre smtp que free cela ne fonctionne pas.
si je prend free le mail s'envoie sans problème. Donc je pense qu'il faut utilisé le smtp approprié au FAI