'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("from_address_here@gmail.com")
'To is a collection of MailAddress types
MyMailMessage.To.Add("to_address_here@domain_name_here")
MyMailMessage.Subject = "GMail Test"
MyMailMessage.Body = "This is the test text for Gmail email"
'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("account uid", " account pwd")
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
MessageBox.Show("Email Sent")
Catch ex As SmtpException
MessageBox.Show(ex.Message)
End Try
Regards
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
Srikanth Kas...
Contributor
4299 Points
883 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:11 AM|LINK
'Start by creating a mail message object Dim MyMailMessage As New MailMessage() 'From requires an instance of the MailAddress type MyMailMessage.From = New MailAddress("from_address_here@gmail.com") 'To is a collection of MailAddress types MyMailMessage.To.Add("to_address_here@domain_name_here") MyMailMessage.Subject = "GMail Test" MyMailMessage.Body = "This is the test text for Gmail email" 'Create the SMTPClient object and specify the SMTP GMail server Dim SMTPServer As New SmtpClient("smtp.gmail.com") SMTPServer.Port = 587 SMTPServer.Credentials = New System.Net.NetworkCredential("account uid", " account pwd") SMTPServer.EnableSsl = True Try SMTPServer.Send(MyMailMessage) MessageBox.Show("Email Sent") Catch ex As SmtpException MessageBox.Show(ex.Message) End TrySrikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
nageshrgosul
Participant
1044 Points
424 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:33 AM|LINK
Hi AlkaSingh ji,
Check once your credentials.
alkasingh
Member
31 Points
36 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:37 AM|LINK
I have cross checked my credentials but m still getting the same error.
Do i need to configure nething in web.config file ??
Mandeep Joon
Participant
1570 Points
387 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:38 AM|LINK
HI,
Try this one:-
http://hightechnology.in/how-to-send-mail-from-asp-net-using-c/
it will help you.
Mark this as answer if it is usefull.
Mandeep Joon
Blog:- Hightechnology.
nijhawan.sau...
All-Star
16460 Points
3178 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:38 AM|LINK
No, you have specified all details in code itself.
nageshrgosul
Participant
1044 Points
424 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 06:46 AM|LINK
Hi just copy and paste these codes...
MailMessage msg = new MailMessage();
msg.From = new MailAddress("xyz@gmail.com");
string mail="abc@gmail.com";
msg.To.Add(mail);
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "ur pwd wright here");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
object userstate = msg;
client.Send(msg);
alkasingh
Member
31 Points
36 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 07:01 AM|LINK
still no progress
nijhawan.sau...
All-Star
16460 Points
3178 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 07:12 AM|LINK
Just for triple check try to send an email from your gmail account by logging in on gmail.com!!
alkasingh
Member
31 Points
36 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 07:23 AM|LINK
yaa i did that
Srikanth Kas...
Contributor
4299 Points
883 Posts
Re: how to send email from asp.net with dynamic contents.
May 09, 2012 07:30 AM|LINK
Do one thing, Since this might be getting caught in catch block, please paste the entire Exception. That will help to troubleshoot your problem.
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.