Bonjour à tous,
Voilà j'ai deux soucis lors de l'envoie d'un email au format HTML...
Mon code VB
Mon code ASP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Imports System.Web.Mail Partial Class _Default Inherits System.Web.UI.Page Sub sendemail(ByVal exp As String, ByVal objet As String, ByVal dest As String, ByVal msg As String, ByVal fic1 As String, ByVal fic2 As String, ByVal fic3 As String) If exp = "" Or dest = "" Then MsgBox("Expéditeur et destinataire obligatoire, merci de compléter !") Else Dim email As New MailMessage() email.From = exp email.To = dest email.Subject = objet email.BodyFormat = MailFormat.Html email.Body = msg email.Priority = MailPriority.High SmtpMail.SmtpServer = "172.16.20.107" Dim attach1 As MailAttachment = New MailAttachment(fic1) email.Attachments.Add(attach1) Dim attach2 As MailAttachment = New MailAttachment(fic2) email.Attachments.Add(attach2) Dim attach3 As MailAttachment = New MailAttachment(fic3) email.Attachments.Add(attach3) Try SmtpMail.Send(email) MsgBox("Message envoyé !") Catch ex As Exception MsgBox("Erreur d'envoie de l'email") End Try End If End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Me.expediteur.Text = "" Me.destinataire.Text = "" Me.objet.Text = "" Me.message.Text = "" Me.fichier1.Text = "" Me.fichier2.Text = "" Me.fichier3.Text = "" End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click sendemail(Me.expediteur.Text, Me.objet.Text, Me.destinataire.Text, Me.message.Text, Me.fichier1.Text, Me.fichier2.Text, Me.fichier3.Text) End Sub End Class
Mes problèmes :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
61 <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript"> </script> <style type="text/css"> #expediteur, #destinataire, #message, #fichier1, #fichier2, #fichier3, #objet { border: 1px solid #6C6C6C; margin-bottom: 2px; } body { font-family: Century Gothic; font-size: 12px; } #Button1, #Button2 { border: 1px solid #6C6C6C; background-color: white; } </style> </head> <body> <form id="form1" runat="server" enctype="multipart/form-data"> <div> <b>Envoie d'un EMAIL</b><br /> <br /> De :<br /> <asp:TextBox ID="expediteur" runat="server" Width="263px"></asp:TextBox> <br /> Objet :<br /><asp:TextBox ID="objet" runat="server" Width="263px"></asp:TextBox> <br /> A :<br /> <asp:TextBox ID="destinataire" runat="server" Width="263px"></asp:TextBox> <br /> Votre Message :<br /><asp:TextBox ID="message" runat="server" Height="179px" Width="478px"></asp:TextBox> <br /> Adresse pièce(s) jointe(s) :<br /> <asp:TextBox ID="fichier1" runat="server" Width="478px"></asp:TextBox> <br /> <asp:TextBox ID="fichier2" runat="server" Width="478px"></asp:TextBox> <br /> <asp:TextBox ID="fichier3" runat="server" Width="478px"></asp:TextBox> <br /> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Envoyer" Width="124px" /> <asp:Button ID="Button2" runat="server" Text="Effacer" Width="113px" /> <br /> </div> </form> </body> </html>
- Impossible de mettre des balises HTMl dans mon Textbox à fin d'envoyer le message au format html...
- Impossible d'envoyer une seul pièce jointe, ma fonction prend les trois pièces jointes en paramètre, comment faire une fonction adaptable ?
Partager