J
Jai
Hi,
I am in a problem of sending mass emails(newsletter) to my website
members.
Actually my problem is this:
I want to send newsletter to my website members. But I had given a
facility for each member to choose different category of products or
all products newsletter.
How can I extract all emails and category options from the database and
accordingly i want to generate a single newsletter for each member.
My ASP.NET 2.0 code:
Sub email()
Dim objDR As OleDbDataReader
Dim sEmail As String
Using connection As New
OleDbConnection(ConfigurationManager.ConnectionStrings("Personal").ConnectionString)
Using command As New OleDbCommand("usp_GetNewsletterEmail",
connection)
Try
command.CommandType = CommandType.StoredProcedure
connection.Open()
objDR =
command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
While objDR.Read()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New
MailAddress("(e-mail address removed)")
sEmail = objDR("UserEmail")
mail.To.Add(sEmail)
'set the content
mail.Subject = "MySite: Weekly Newsletter"
'first we create the Plain Text part
Dim plainView As AlternateView =
AlternateView.CreateAlternateViewFromString("This is my plain text
content, viewable by those clients that don't support html", Nothing,
"text/plain")
'then we create the Html part
Dim htmlView As AlternateView =
AlternateView.CreateAlternateViewFromString("<b>this is bold text, and
viewable by those mail clients that support html</b>", Nothing,
"text/html")
mail.AlternateViews.Add(plainView)
mail.AlternateViews.Add(htmlView)
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
'specify the mail server address
smtp.Send(mail)
End While
Catch ex As Exception
End Try
End Using
End Using
End Sub
In the above code, I am able to extract email address of each member
but the problem is that each members has its own option for newsletter
like somebody wants to get newletter of "Hardware", and somebody else
wants "Hardware + Software + Electronics" and someother one wants "ALL
Products".................
I am storing all these options in my database against each user email
address.............
now when i am fetching emails and options(each user has its own
options) from the database...
i am able to send newsletter to each member but not with its own
options.
Please help me..........how will i be able to send newsletter to my
each members with its own options..so that the members get the email at
once....
Please tell me how the newsletter contains the images....with
scheduling(automatic emails once in a week).
With Regards,
I am in a problem of sending mass emails(newsletter) to my website
members.
Actually my problem is this:
I want to send newsletter to my website members. But I had given a
facility for each member to choose different category of products or
all products newsletter.
How can I extract all emails and category options from the database and
accordingly i want to generate a single newsletter for each member.
My ASP.NET 2.0 code:
Sub email()
Dim objDR As OleDbDataReader
Dim sEmail As String
Using connection As New
OleDbConnection(ConfigurationManager.ConnectionStrings("Personal").ConnectionString)
Using command As New OleDbCommand("usp_GetNewsletterEmail",
connection)
Try
command.CommandType = CommandType.StoredProcedure
connection.Open()
objDR =
command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
While objDR.Read()
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New
MailAddress("(e-mail address removed)")
sEmail = objDR("UserEmail")
mail.To.Add(sEmail)
'set the content
mail.Subject = "MySite: Weekly Newsletter"
'first we create the Plain Text part
Dim plainView As AlternateView =
AlternateView.CreateAlternateViewFromString("This is my plain text
content, viewable by those clients that don't support html", Nothing,
"text/plain")
'then we create the Html part
Dim htmlView As AlternateView =
AlternateView.CreateAlternateViewFromString("<b>this is bold text, and
viewable by those mail clients that support html</b>", Nothing,
"text/html")
mail.AlternateViews.Add(plainView)
mail.AlternateViews.Add(htmlView)
'send the message
Dim smtp As New SmtpClient("127.0.0.1")
'specify the mail server address
smtp.Send(mail)
End While
Catch ex As Exception
End Try
End Using
End Using
End Sub
In the above code, I am able to extract email address of each member
but the problem is that each members has its own option for newsletter
like somebody wants to get newletter of "Hardware", and somebody else
wants "Hardware + Software + Electronics" and someother one wants "ALL
Products".................
I am storing all these options in my database against each user email
address.............
now when i am fetching emails and options(each user has its own
options) from the database...
i am able to send newsletter to each member but not with its own
options.
Please help me..........how will i be able to send newsletter to my
each members with its own options..so that the members get the email at
once....
Please tell me how the newsletter contains the images....with
scheduling(automatic emails once in a week).
With Regards,