Est-ce quelqu'un sait intégrer des images dans le corps d'un mail (vb net)?

cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 - 29 juil. 2005 à 16:25
renocmoa Messages postés 134 Date d'inscription mardi 7 septembre 2004 Statut Membre Dernière intervention 10 mai 2012 - 17 août 2006 à 12:49
Bonjour,

J'essai d'envoyer un mail via la classe mail de vb net : system.web.mail

seulement aucune image intégrée dans le corps du message n'est visible à l'arrivée...

j'essai d'utiliser word pour faire comme outlook c'est à dire intégrer une image via le script editor de word seulement ça ne fonctionne pas...

Le problème majeur étant que je ne peux pas me servir du copier coller à cause d'une interraction événementielle d'excel qui change le thread de mon application ce qui fait planter le clipboard...

J'utilise un control RTF et j'insère l'image dedans puis lorsque je transforme le texte en html via word l'image disparait du fichier lorsque je l'ouvre avec internet explorer ou outlook mais est toujours là si je l'ouvre avec word...

Quelqu'un a une idée ?

22 réponses

cs_eldim Messages postés 956 Date d'inscription lundi 30 mai 2005 Statut Membre Dernière intervention 21 août 2014 1
13 déc. 2005 à 17:15
Salut !
utilise BLAT sur sourceforge
c'est l'idéal
0
renocmoa Messages postés 134 Date d'inscription mardi 7 septembre 2004 Statut Membre Dernière intervention 10 mai 2012
17 août 2006 à 12:49
'first we create the Plain Text part






Dim
plainView

As
AlternateView = AlternateView.CreateAlternateViewFromString("

Mon Texte de secours"
,

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 will map to a LinkedResource with a ContentId of 'companylogo'






Dim
htmlView

As
AlternateView = AlternateView.CreateAlternateViewFromString(

"Here is an embedded image.
,

Nothing
,

"text/html"
)


'create the LinkedResource (embedded image)






Dim
logo

As



New
LinkedResource(

"C:\MonImage.jpg"
)logo.ContentId =


"companylogo"






'add the LinkedResource to the appropriate view

htmlView.LinkedResources.Add(logo)










' Creating a mail message is as simple as instantiating a class and






' setting a few properties.






Dim
mailMsg

As



New
Net.Mail.MailMessage()


With
mailMsg


If
txtFrom.Text <>

""



Then
.From =

New
MailAddress(txtFrom.Text.Trim).To.Add(txtTo.Text.Trim)


'.CC.Add(txtCC.Text.Trim)






'.Bcc.Add(txtBCC.Text.Trim)

.Subject = txtSubject.Text.Trim


.Body =




Me
.txtBody.Text.Priority =


CType
(cboPriority.SelectedIndex, MailPriority)


'add the views

.AlternateViews.Add(plainView)


.AlternateViews.Add(htmlView)







If



Not
IsNothing(arlAttachments)

Then






Dim
mailAttachment

As



Object






For



Each
mailAttachment

In
arlAttachments.Attachments.Add(


New
Attachment(mailAttachment.ToString))


Next






End



If






End



With






' Set the SmtpServer name. This can be any of the following depending on






' your local security settings: 








' See the Readme file for more information.






Dim
SMTP

As



New
SmtpClient(

"Mon Serveur smtp"
)


'SmtpMail.SmtpServer = "smarthost"






' Use structured error handling to attempt to send the email message and






' provide feedback to the user about the success or failure of their






' attempt.






Try

SMTP.Send(mailMsg) ......





reno
0
Rejoignez-nous