1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| Sub Envoyer_email()
Dim sfilename As String
sfilename = Server.MapPath("/dsw/client/" & session_client.code_client & "/ETK_" & session_assemblee.code_assemblee & ".htm")
Dim fs As New IO.FileStream(sfilename, IO.FileMode.Create, IO.FileAccess.Write)
Dim sw As New IO.StreamWriter(fs)
Dim txt_email As String
Dim ck_txt As String
txt_email = 'tout un gros paquet de code pour formater un email html
Dim dswpdf As DSWPDF.Service = New DSWPDF.Service
dswpdf.Make_DSW_PDF(sfilename, session_client.code_client)
'Response.Write(txt_email)
Dim exptab() As String = Split(exp.Text, ";")
Dim send As String
For Each send In exptab
Dim mMail As MailMessage = New MailMessage
mMail.Headers.Add("Return-Receipt-To", send)
mMail.BodyFormat = MailFormat.Html
mMail.Body = "Please find enclosed the admission ticket"
mMail.Subject = "Eintrittskarte für die Hauptversammlung der " & Raison_sociale.Text & " am " & Datum_ag.Text
mMail.From = send
mMail.To = dest.Text
mMail.Attachments.Add(New System.Web.Mail.MailAttachment(Replace(sfilename, ".htm", ".pdf")))
If dest2.Text <> "" Then
mMail.To = mMail.To & ";" & dest2.Text
End If
If dest3.Text <> "" Then
mMail.To = mMail.To & ";" & dest3.Text
End If
'mMail.Cc = "xxxxx@xxx.com"
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "mail.xxxxxxxx.fr")
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "moi@xxxxxxxx.fr")
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxx")
Try
SmtpMail.Send(mMail)
lbl_ok.Visible = True
lbl_error.Visible = False
Catch ex As Exception
lbl_ok.Visible = False
lbl_error.Visible = True
End Try
Next
End Sub |
Partager