473,509 Members | 2,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Way Html Formatted Email

What's the best way to send html formatted email (newsletter style)?
In Code or In Web Config files? I'm thinking in code using StringWriter and
HtmlTextWriter?
Nov 18 '05 #1
2 1129
I'm not sure what you mean with "in Web config files" Typically you'd build
a string (stringbuilder is a smart idea) ala:

Dim sb As New StringBuilder
sb.append(...)

Dim message As New Mail.MailMessage
message.BodyFormat = Mail.MailFormat.Html
message.Body = sb.ToString()
It might also be a good idea to store your messages in an XML file with
placeholders and use a strongly-type object, a very incomplete example:
<emailMessage id="1">
<to>{userEmail}</to>
<from>{systemEmail}</from>
<subject>Account Information</subject>
<body>Dear {userName},
Here is the requested account information:
Password: {newPassword}
Thanks,
{adminName}
</body>
</emailMessage>

dim messag as CustomMailMessageObject = getMessage(1)
message.to = message.to.replace("{userEmail}", user.Email);
message.from = message.to.replace("{systemEmail}",
configuration.SystemEmail);
dim body as new StringBuilder(message.Body);
body.replace("{userName}", user.Name);
body.replace("{newPassword}", user.Password);
body.replace("{adminName}, configuration.AdminName);

This gives you the added flexibility of not having your emails hard-coded in
your application.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
What's the best way to send html formatted email (newsletter style)?
In Code or In Web Config files? I'm thinking in code using StringWriter and HtmlTextWriter?

Nov 18 '05 #2
Thanks! what I meant by "Web config files" is XML file sorry.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:up**************@TK2MSFTNGP15.phx.gbl...
I'm not sure what you mean with "in Web config files" Typically you'd
build
a string (stringbuilder is a smart idea) ala:

Dim sb As New StringBuilder
sb.append(...)

Dim message As New Mail.MailMessage
message.BodyFormat = Mail.MailFormat.Html
message.Body = sb.ToString()
It might also be a good idea to store your messages in an XML file with
placeholders and use a strongly-type object, a very incomplete example:
<emailMessage id="1">
<to>{userEmail}</to>
<from>{systemEmail}</from>
<subject>Account Information</subject>
<body>Dear {userName},
Here is the requested account information:
Password: {newPassword}
Thanks,
{adminName}
</body>
</emailMessage>

dim messag as CustomMailMessageObject = getMessage(1)
message.to = message.to.replace("{userEmail}", user.Email);
message.from = message.to.replace("{systemEmail}",
configuration.SystemEmail);
dim body as new StringBuilder(message.Body);
body.replace("{userName}", user.Name);
body.replace("{newPassword}", user.Password);
body.replace("{adminName}, configuration.AdminName);

This gives you the added flexibility of not having your emails hard-coded
in
your application.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Leon" <vn*****@msn.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
What's the best way to send html formatted email (newsletter style)?
In Code or In Web Config files? I'm thinking in code using StringWriter

and
HtmlTextWriter?


Nov 18 '05 #3

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

Similar topics

5
2231
by: Paul Lamonby | last post by:
Hi, I am generating a HTML formatted email in PHP, but I am getting the most bizarre error, it will randomly delete characters out of the HTML code while in transit to the address, therefore...
3
4712
by: Niel | last post by:
Hello friends, Don't know if i am posting to the right group, but if anyone has an idea about this please let me know. I just wanted to ask that is it true that it is not possible to send HTML...
2
2911
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
258
8367
by: Terry Andersen | last post by:
If I have: struct one_{ unsigned int one_1; unsigned short one_2; unsigned short one_3; }; struct two_{ unsigned int two_1;
2
1741
by: Paul Turley | last post by:
Does anyone have some sample code for sending an HTML formatted message using CDONTS? Thanks RE: Sending HTML formatted mail using CDONTS -- Paul Turley, MCSD, MCAD, MCT, MSF...
1
2929
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the...
4
5055
by: cybervigilante | last post by:
I sent HTML formatted email, using PHP, to my Yahoo address from my server, and it came out fine, styles and all. I sent it to my gmail address to test it and all I see is the raw html code. But I...
2
3814
by: Big Moxy | last post by:
I want to send html formatted text yet strip out special characters (e.g. quotes and semi colons). I've seen preg_replace examples like $messageout = preg_replace('/\(\)<>]/i','',$message); to...
1
4566
by: robnoper | last post by:
XP SP2, access and outlook 2003 I have a form with 3 command buttons on that when one is pressed it opens up a html email for the user to send. Two of the emails work fine and open with the full...
0
7234
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
7344
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
7412
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...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4730
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.