my content will change everyday. how can i achieve this? Where will i put my content ??
Well this line basically means the content is dynamic, yo just have to assign your content to this string "strBuildYourMessage", maybe put this email code in a fucntion and pass in this string and your email would always be dynamic as per the string you
pass.
mail.From = New MailAddress("xyz@gmail.com")
mail.To.Add("abc@gmail.com")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail from GMAIL"
Client.Send(mail)
MsgBox("mail send")
Catch ex As Exception
Response.Write(ex.Message)
Return
End Try
alkasingh
Member
31 Points
36 Posts
how to send email from asp.net with dynamic contents.
May 08, 2012 09:23 AM|LINK
how to send email from asp.net with dynamic contents.
Guys pls reply
nijhawan.sau...
All-Star
16400 Points
3173 Posts
Re: how to send email from asp.net with dynamic contents.
May 08, 2012 09:30 AM|LINK
Sample code. Use your smtp settings:
System.Net.Mail; //Include This NameSpace MailMessage MyMailMessage = new MailMessage(); MyMailMessage.From = new MailAddress("adbuaryuy@gmail.com"); MyMailMessage.To.Add("yearningpeeks@yahoo.com"); MyMailMessage.Subject = "Feedback Form"; MyMailMessage.IsBodyHtml = true; MyMailMessage.Body = "<table><tr><td>" + txtName.Text + txtEmail.Text + txtComments.Text + "</table></tr></td>"; SmtpClient SMTPServer = new SmtpClient("smtp.gmail.com"); SMTPServer.Port = 587; SMTPServer.Credentials = new System.Net.NetworkCredential("adbuaryuy@gmail.com", System.Configuration.ConfigurationSettings.AppSettings["pwd"].ToString()); SMTPServer.EnableSsl = true; try { SMTPServer.Send(MyMailMessage); Response.Redirect("Thankyou.aspx"); } catch (Exception ex) { }santosh.jagd...
Star
7625 Points
1454 Posts
Re: how to send email from asp.net with dynamic contents.
May 08, 2012 09:31 AM|LINK
MailMessage msg = new MailMessage(); msg.To = txtTo.Text; msg.From = txtFrom.Text; msg.Subject = txtSubject.Text; msg.Body = strBuildYourMessage; lblStatus.Text = "Sending..."; SmtpMail.SmtpServer = "smtp.yourISP.com"; SmtpMail.Send(msg); lblStatus.Text = "Sent email (" + txtSubject.Text + ") to " + txtTo.Text;MCP
alkasingh
Member
31 Points
36 Posts
Re: how to send email from asp.net with dynamic contents.
May 08, 2012 09:39 AM|LINK
pls explain this as m doing this for first time.
tusharrs
Contributor
3230 Points
668 Posts
Re: how to send email from asp.net with dynamic contents.
May 08, 2012 09:43 AM|LINK
store the content in database
retrieve from database and assign it to msg.Body
( Mark as Answer if it helps you out )
View my Blog
nijhawan.sau...
All-Star
16400 Points
3173 Posts
Re: how to send email from asp.net with dynamic contents.
May 08, 2012 09:58 AM|LINK
Well this line basically means the content is dynamic, yo just have to assign your content to this string "strBuildYourMessage", maybe put this email code in a fucntion and pass in this string and your email would always be dynamic as per the string you pass.
suresh dasar...
Contributor
3606 Points
743 Posts
Re: how to send email from asp.net with dynamic contents.
May 08, 2012 02:14 PM|LINK
hi alkasingh
check these links
http://www.aspdotnet-suresh.com/2010/11/introduction-this-article-i-will.html
http://www.aspdotnet-suresh.com/2010/12/how-to-send-mail-using-gmail.html
http://www.aspdotnet-suresh.com/2010/12/how-to-send-mail-with-images-using.html
Please "Mark as Answer" If post helps you
alkasingh
Member
31 Points
36 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 05:57 AM|LINK
m getting this error pls help
"Failure Sending Mail"
Here is my Code
Protected Sub cmdSendEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSendEmail.Click
Try
Dim Client As New SmtpClient()
Dim mail As New MailMessage()
Client.Host = "smtp.gmail.com"
Client.Port = 587
Client.EnableSsl = True
Client.UseDefaultCredentials = True
Client.Credentials = New Net.NetworkCredential("xyz@gmail.com", "******")
mail.From = New MailAddress("xyz@gmail.com")
mail.To.Add("abc@gmail.com")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail from GMAIL"
Client.Send(mail)
MsgBox("mail send")
Catch ex As Exception
Response.Write(ex.Message)
Return
End Try
End Sub
nijhawan.sau...
All-Star
16400 Points
3173 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:05 AM|LINK
Everything seems to be ok, double check your Username and pwd.
amit.jain
Star
11225 Points
1815 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:09 AM|LINK
Client.Credentials = New Net.NetworkCredential("xyz@gmail.com", "******") [Use your correct gmail id and password for credentials ]
mail.From = New MailAddress("xyz@gmail.com") [use your gmail is here ]
refer http://www.csharpaspnetarticles.com/2009/08/send-email-using-gmail-in-aspnet.html
http://www.csharpaspnetarticles.com/2009/10/send-email-with-attachment-in-aspnet.html for more info
amiT jaiN
ASP.NET C# VB Articles And Code Examples