Friday, March 16, 2012

Newsletter

How to create newsletter in asp.net 2.0?
How to manage email list?
how can user subscribe and unsubscribe?

Hi,
- all kinds of questions about emailing from .NET can be found here:http://www.systemwebmail.com.
- to manage a list of subscribers you could use a webform with a grid on it.
- you can have a page where a person can subscribe. In ASP.NET 2.0 the CreateUserWizard would be a nice control to take a look at for this purpose. After that you can send a confirmation email to make sure that the person who subscribed really owns that emailaddress.
Grz, Kris.


is it possible to create newsletter using any html editor and use that page in your asp.net so that you dont have to write all the html code in asp.net.


Hi,
you could that,read it out using a streamreader and use it to fill up the body of the mail message. Another way could be that you use atext editor like where you type in your questions on this forum and save it into a database. It seems handier to me to do so because you don't have to make up any html and upload it to a server.
Grz, Kris.
That helps. you have any example I can check online.
Hi,
you want an example for...?
If you want to put something into a database you'll be needingADO.NET. The freetextbox I mentioned in my previous post is a free webcontrol that you can download and use. The link to the "reading text from a file" in my previous post shows you how to use the StreamReader class to read from a file.
Grz, Kris.
I tried the below code and it just sends me an blank email. newsletter.htm is a html page with simple newsletter. I also had to put full path for this. I tried "./images/newsletter.htm" and it ended up with error ( cannot find newsletter.htm in c:\windows\system32).
What am I doing wrong here?
Private Const FILE_NAME As String = "C:\Inetpub\wwwroot\Intranet\images\newsletter.htm"
Dim email As MailMessage
If Not File.Exists(FILE_NAME) Then
Console.WriteLine("{0} does not exist.", FILE_NAME)
Return
End If
Dim sr As StreamReader = File.OpenText(FILE_NAME)
Dim input As String
input = sr.ReadLine()
Dim strnews As String
SmtpMail.SmtpServer = "localhost"
email = New MailMessage
email.BodyFormat = MailFormat.Html
email.From =emailme@.email.com
email.To = ("emailme@.email.com")
email.Subject = "News Letter"
While Not input Is Nothing
input = sr.ReadLine()
strnews = input
End While

Hi,
at first glance you missed a property of the MailMessage class:Body. Besides that your code doesn't seem quite clean to me.

While Not input Is Nothing
input = sr.ReadLine()
strnews = input
End While
Why do you assign a string to another string? Also it would be better to write it like this:
strnews += input so you concatenate the strings, now you're just simply replacing them.
Another thing, and even more important, is the fact that you use simple strings to concatenate. This can be done as long as the concatenating doesn't take more than 5 times. Because a string is immutable, every time you concatenate a new string is created. So it's better to use aStringBuilder instance in this case.
So it would be more like this:

Dim sr As StreamReader = File.OpenText(FILE_NAME)
Dim input As New StringBuilder()
SmtpMail.SmtpServer = "localhost"
email = New MailMessage
email.BodyFormat = MailFormat.Html
email.From = emailme@.email.com
email.To = ("emailme@.email.com")
email.Subject = "News Letter"
String strNews
Do strNews = sr.ReadLine()
input.Append(strNews)
Loop Until line Is Nothing
sr.Close()
email.Body = input.ToString()
This code isn't tested and I didn't have any coffee yet.
Grz, Kris.


Hi
Prevent potentially dangerous HTML Tags:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000004.asp
Regards

I want to start with a simple newsletter. First step I want to send out and HTML page. When I try that, it does not display any pictures when viewed in email. Any better way to work on this.
Dim strnewsAsString

SmtpMail.SmtpServer = "w2k3-exch1.360incliv.com"

email =New MailMessage

email.BodyFormat = MailFormat.Html

email.From = "bpatel@.360inc.com"

email.To = ("bpatel@.360inc.com")

email.Subject = "News Letter"

Dim attachmentAsNew MailAttachment(Server.MapPath("newsletter.htm"))'create the attachment

email.Attachments.Add(attachment)'add the attachment

SmtpMail.Send(email)

0 comments:

Post a Comment