|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
MailMessage to send email with both Text and HTML versions...I have an app that has beenusing the JMail COM component to generate emails. I would like to switch to the using the .Net 2.0 MailMessage object instead - as it is more portable. The jmail component allowed me to set both an HTML body and a text body - this meant that if a users' email client didn't support html - the user would see the text only version with an html attachment. The MailMessage object only appears to have one Body setting and you have to switch it between IsHtml or not. Is there any way of sending both text and html versions in one email as jmail does - but using interval .Net objects? Thanks in advance, Stu Dim oSmtp As New SmtpClient oSmtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory oSmtp.PickupDirectoryLocation = "c:\Pickup\" oSmtp.UseDefaultCredentials = True Dim oMsg As New MailMessage() oMsg.From = New MailAddress(myfromn***@domain.com) oMsg.To.Add(New MailAddress***@domain.com) oMsg.Subject = "My Subject..." oMsg.IsBodyHtml = True oMsg.Body = "My HTML...blah..." oSmtp.Send(oMsg)
Show quote
Hide quote
On Sat, 29 Apr 2006 11:36:31 +0100, "Stu Lock" <s.l***@cergis.com> Take a look at the AlternateViews propert of MailMessage. By the lookswrote: >Hi, > >I have an app that has beenusing the JMail COM component to generate emails. >I would like to switch to the using the .Net 2.0 MailMessage object >instead - as it is more portable. > >The jmail component allowed me to set both an HTML body and a text body - >this meant that if a users' email client didn't support html - the user >would see the text only version with an html attachment. The MailMessage >object only appears to have one Body setting and you have to switch it >between IsHtml or not. > >Is there any way of sending both text and html versions in one email as >jmail does - but using interval .Net objects? > >Thanks in advance, > >Stu > >Dim oSmtp As New SmtpClient >oSmtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory >oSmtp.PickupDirectoryLocation = "c:\Pickup\" >oSmtp.UseDefaultCredentials = True >Dim oMsg As New MailMessage() >oMsg.From = New MailAddress(myfromn***@domain.com) >oMsg.To.Add(New MailAddress***@domain.com) >oMsg.Subject = "My Subject..." >oMsg.IsBodyHtml = True >oMsg.Body = "My HTML...blah..." >oSmtp.Send(oMsg) > of it you need to send the main message as plain text, and attach the richer versions (such as html) as an alternate view. Although I have no idea how any of that works so you'll just have to play with it (I just got this by looking at the docs).
Export nText as Files
BeginInvoke with a property? Loading controls with objects versus recordsets DataTable Loop and String Building TAG Property Is there an easy way to get my Subnet Mask? inheritance question Cast from string to System.DayOfWeek vb.Script to VB.NET 2005 Stored Procedure runs in SQL Server Management Studio but not in VB |
|||||||||||||||||||||||