Bonjour,
je voudrai pouvoir envoyer un mail en VB.net avec une image en fond d'ecran.
je cherche donc a utiliser l'envoi en mode html mais je dois mal m'y prendre.
Quelqu'un aurait il un exemple ?
Merci d'avance
@+ Vijeo
Bonjour,
je voudrai pouvoir envoyer un mail en VB.net avec une image en fond d'ecran.
je cherche donc a utiliser l'envoi en mode html mais je dois mal m'y prendre.
Quelqu'un aurait il un exemple ?
Merci d'avance
@+ Vijeo
J'avais trouvé un bout de code qui expliquait comment insérer une image dans un mail envoyé via .net
Voici la fonction :
En éspérant que ça puisse t'aider.
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 Sub EmbedImages() 'create the mail message Dim mail As New Net.Mail.MailMessage() 'set the addresses mail.From = New Net.Mail.MailAddress("Expediteur@Domaine.com") mail.To.Add("Destinataire@gmail.com") 'set the content mail.Subject = "This is an email" 'first we create the Plain Text part Dim plainView As Net.Mail.AlternateView = Net.Mail.AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", Nothing, "text/plain") 'then we create the Html part 'to embed images, we need to use the prefix 'cid' in the img src value 'the cid value will map to the Content-Id of a Linked resource. 'thus <img src='cid:companylogo'> will map to a LinkedResource with a ContentId of 'companylogo' Dim htmlView As Net.Mail.AlternateView = Net.Mail.AlternateView.CreateAlternateViewFromString("Here is an embedded image.<img src=cid:companylogo>", Nothing, "text/html") 'create the LinkedResource (embedded image) Dim logo As New Net.Mail.LinkedResource("c:\logo.jpg") logo.ContentId = "companylogo" 'add the LinkedResource to the appropriate view htmlView.LinkedResources.Add(logo) 'add the views mail.AlternateViews.Add(plainView) mail.AlternateViews.Add(htmlView) 'send the message Dim smtp As New Net.Mail.SmtpClient("smtpin.ati.tn") 'specify the mail server address smtp.Send(mail) End Sub 'EmbedImages
Edit : Je précise que je ne l'ai pas testé, mais ça m'a l'air correct...
Bonjour,
Ce sujet a été traité maintes fois
Tu as des exemples dans le forum et dans les tuto de www.developpez.com
Bonne chance.
Notalp![]()
le code ci dessus fonctionne parfaitement
Merci pour votre aide
@+ Vijeo
Partager