473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

MailMessage to send email with both Text and HTML versions...

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(my********@domain.com)
oMsg.To.Add(New MailAddress(me@domain.com)
oMsg.Subject = "My Subject..."
oMsg.IsBodyHtml = True
oMsg.Body = "My HTML...blah..."
oSmtp.Send(oMsg)
Apr 29 '06 #1
1 4608
On Sat, 29 Apr 2006 11:36:31 +0100, "Stu Lock" <s.****@cergis.com>
wrote:
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(my********@domain.com)
oMsg.To.Add(New MailAddress(me@domain.com)
oMsg.Subject = "My Subject..."
oMsg.IsBodyHtml = True
oMsg.Body = "My HTML...blah..."
oSmtp.Send(oMsg)


Take a look at the AlternateViews propert of MailMessage. By the looks
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).
Apr 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: LRW | last post by:
I'm not sure this message is totally appropriate for this group, so please, if anyone has a better group suggestion, let me know! My company sends out a monthly newsletter in HTML format to our...
5
by: Simran | last post by:
I need to set up an automated email system , which means users should not be able to respond back to the emails but at the same time, we need to track bounced emails. This is important as our...
6
by: Frank | last post by:
Straightforward VB.NET 2002 code that works form both Windows and ASP.NET apps on a Windows 2000 machine, and works in the Windows app on a newly installed XP machine, but fails in the ASP.NET...
5
by: martin | last post by:
Hi, I have created a class that is totally seperate from my web application. However this class is used extensivly by the web application for stuff like data access. I wish to add a function to...
0
by: Scott Townsend | last post by:
I'm trying to send an email and get a delivery receipt back. I'm setting the MailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess and it works great for the First email...
4
by: Ant | last post by:
Hi, I'm using the MailMessage object to send an email programmatically via a console application. It needs to have lines breaks. For example: string s = "This is the first line + "\n\r" + "and...
2
by: | last post by:
Hi, I am having problem sending email to external mailbox using HTML format. Following is a simplified code that I used to send the email. Dim myMsg As New MailMessage Dim htmlBody As String...
5
by: Vlad | last post by:
We are trying to set MailMessage Content-Type to be text/calendar The following code has been used: string subject = "Calendar test 3"; MailMessage emailMessage = new MailMessage();...
2
by: =?Utf-8?B?Q2FwdGFpbiBEYXZlIQ==?= | last post by:
I wrote some code to send an email with two alternate views: 1) html 2) plain text All the html enabled email clients accept the html just fine and disregard the plain text version. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.