voila ce matin j'ai adapter mon code VMail windows sur linux.
une fois compiler, il permet d'envoyer des mail facilement ( sans aucun réglage pop etc..) avec 1 piece jointe.
voici la source :
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
InitNetwork()
If OpenWindow(#Window_0, 0, 0, 600, 375, "VMail", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
Frame3DGadget(#Frame3D_0, 10, 10, 580, 260, "")
Frame3DGadget(#Frame3D_1, 10, 285, 175, 60, "votre fournisseur")
Frame3DGadget(#Frame3D_2, 415, 285, 175, 60, "Envoyer")
Frame3DGadget(#Frame3D_3, 210, 285, 175, 60, "Pièce jointe")
TextGadget(#Text_0, 20, 35, 25, 20, "De:")
TextGadget(#Text_1, 20, 65, 20, 20, "A:")
TextGadget(#Text_2, 15, 95, 40, 20, "Objet:")
StringGadget(#String_0, 60, 30, 520, 20, "")
StringGadget(#String_1, 60, 60, 520, 20, "")
StringGadget(#String_2, 60, 90, 520, 20, "")
EditorGadget(#String_3, 20, 120, 560, 140)
ComboBoxGadget(#Combo_0, 20, 305, 155, 30)
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, 30, "Envoyer")
ButtonGadget(#Button_1, 220, 305, 155, 30, "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)
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
@++