Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > send mail with gmail

Reply
Thread Tools

send mail with gmail

 
 
fredd00
Guest
Posts: n/a
 
      02-18-2008
Hi

i'm trying to send email through my gmail account, used to work

web.config

<system.net>
<mailSettings>
<smtp from="myfrom" >
<network defaultCredentials="true" host="smtp.gmail.com"
port="465" userName="mygmailusername" password="mygmailpassword"/>
</smtp>
</mailSettings>
</system.net>

my fonction

public static void SendEmail(string To, string From, string Subject,
string Body, bool IsBodyHtml)
{
try
{
using (MailMessage message = new MailMessage(From, To,
Subject, Body))
{
message.IsBodyHtml = IsBodyHtml;
SmtpClient mailClient = new SmtpClient();
mailClient.Send(message);
}
}
catch (SmtpException ex)
{
throw new ApplicationException("SmtpException has
Occured: " + ex.Message);
}
}

i get either error :
1-
SmtpException has Occured: The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: 5.7.0 Must issue a STARTTLS command first e13sm6192679qba.37

or
2 - when i enable ssl
SmtpException has Occured: The SMTP server requires a secure
connection or the client was not authenticated. The server response
was: 5.5.1 Authentication Required e11sm6169311qbc.5


who can it be solved ?
also who can i use this account to send email through the password
recovery control ?
thanks
 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      02-18-2008


I have downloadable code.
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry

there...with gmail specific settings as well.


Download the code. Change a couple of settings (Your username and password)
and it should work for you.





"fredd00" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> i'm trying to send email through my gmail account, used to work
>
> web.config
>
> <system.net>
> <mailSettings>
> <smtp from="myfrom" >
> <network defaultCredentials="true" host="smtp.gmail.com"
> port="465" userName="mygmailusername" password="mygmailpassword"/>
> </smtp>
> </mailSettings>
> </system.net>
>
> my fonction
>
> public static void SendEmail(string To, string From, string Subject,
> string Body, bool IsBodyHtml)
> {
> try
> {
> using (MailMessage message = new MailMessage(From, To,
> Subject, Body))
> {
> message.IsBodyHtml = IsBodyHtml;
> SmtpClient mailClient = new SmtpClient();
> mailClient.Send(message);
> }
> }
> catch (SmtpException ex)
> {
> throw new ApplicationException("SmtpException has
> Occured: " + ex.Message);
> }
> }
>
> i get either error :
> 1-
> SmtpException has Occured: The SMTP server requires a secure
> connection or the client was not authenticated. The server response
> was: 5.7.0 Must issue a STARTTLS command first e13sm6192679qba.37
>
> or
> 2 - when i enable ssl
> SmtpException has Occured: The SMTP server requires a secure
> connection or the client was not authenticated. The server response
> was: 5.5.1 Authentication Required e11sm6169311qbc.5
>
>
> who can it be solved ?
> also who can i use this account to send email through the password
> recovery control ?
> thanks



 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      02-18-2008
Try doing it with a chunky method:


using System;
using System.Collections.Generic;
using System.Text;

namespace PAB.SEO
{
public static class GmailSender
{
public static void SendGmail(string userName, string password,
string mailFrom,
string mailTo, string commaDelimCCs, string
subject, string message, bool isBodyHtml)
{
System.Net.Mail.MailMessage msg = new
System.Net.Mail.MailMessage(mailFrom, mailTo,
subject, message);
msg.IsBodyHtml = isBodyHtml;
if(commaDelimCCs!="")
msg.CC.Add(commaDelimCCs );
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential(userName, password);
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = cred;
mailClient.Send(msg);
}
}
}

--Peter
Site: http://www.eggheadcafe.com
UnBlog: htp://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net


"fredd00" wrote:

> Hi
>
> i'm trying to send email through my gmail account, used to work
>
> web.config
>
> <system.net>
> <mailSettings>
> <smtp from="myfrom" >
> <network defaultCredentials="true" host="smtp.gmail.com"
> port="465" userName="mygmailusername" password="mygmailpassword"/>
> </smtp>
> </mailSettings>
> </system.net>
>
> my fonction
>
> public static void SendEmail(string To, string From, string Subject,
> string Body, bool IsBodyHtml)
> {
> try
> {
> using (MailMessage message = new MailMessage(From, To,
> Subject, Body))
> {
> message.IsBodyHtml = IsBodyHtml;
> SmtpClient mailClient = new SmtpClient();
> mailClient.Send(message);
> }
> }
> catch (SmtpException ex)
> {
> throw new ApplicationException("SmtpException has
> Occured: " + ex.Message);
> }
> }
>
> i get either error :
> 1-
> SmtpException has Occured: The SMTP server requires a secure
> connection or the client was not authenticated. The server response
> was: 5.7.0 Must issue a STARTTLS command first e13sm6192679qba.37
>
> or
> 2 - when i enable ssl
> SmtpException has Occured: The SMTP server requires a secure
> connection or the client was not authenticated. The server response
> was: 5.5.1 Authentication Required e11sm6169311qbc.5
>
>
> who can it be solved ?
> also who can i use this account to send email through the password
> recovery control ?
> thanks
>

 
Reply With Quote
 
fredd00
Guest
Posts: n/a
 
      02-20-2008
i'm still getting the error
The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.7.0 Must issue a STARTTLS
command first f18sm8426670qba.14

but the emails seems to be sent anyway, i'm receiving my message


On Feb 18, 1:31 pm, Peter Bromberg [C# MVP]
<(E-Mail Removed)> wrote:
> Try doing it with a chunky method:
>
> using System;
> using System.Collections.Generic;
> using System.Text;
>
> namespace PAB.SEO
> {
> public static class GmailSender
> {
> public static void SendGmail(string userName, string password,
> string mailFrom,
> string mailTo, string commaDelimCCs, string
> subject, string message, bool isBodyHtml)
> {
> System.Net.Mail.MailMessage msg = new
> System.Net.Mail.MailMessage(mailFrom, mailTo,
> subject, message);
> msg.IsBodyHtml = isBodyHtml;
> if(commaDelimCCs!="")
> msg.CC.Add(commaDelimCCs );
> System.Net.NetworkCredential cred = new
> System.Net.NetworkCredential(userName, password);
> System.Net.Mail.SmtpClient mailClient = new
> System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
> mailClient.EnableSsl = true;
> mailClient.UseDefaultCredentials = false;
> mailClient.Credentials = cred;
> mailClient.Send(msg);
> }
> }
>
> }
>
> --Peter
> Site:http://www.eggheadcafe.com
> UnBlog: htp://petesbloggerama.blogspot.com
> Short Urls & more:http://ittyurl.net
>
> "fredd00" wrote:
> > Hi

>
> > i'm trying to send email through my gmail account, used to work

>
> > web.config

>
> > <system.net>
> > <mailSettings>
> > <smtp from="myfrom" >
> > <network defaultCredentials="true" host="smtp.gmail.com"
> > port="465" userName="mygmailusername" password="mygmailpassword"/>
> > </smtp>
> > </mailSettings>
> > </system.net>

>
> > my fonction

>
> > public static void SendEmail(string To, string From, string Subject,
> > string Body, bool IsBodyHtml)
> > {
> > try
> > {
> > using (MailMessage message = new MailMessage(From, To,
> > Subject, Body))
> > {
> > message.IsBodyHtml = IsBodyHtml;
> > SmtpClient mailClient = new SmtpClient();
> > mailClient.Send(message);
> > }
> > }
> > catch (SmtpException ex)
> > {
> > throw new ApplicationException("SmtpException has
> > Occured: " + ex.Message);
> > }
> > }

>
> > i get either error :
> > 1-
> > SmtpException has Occured: The SMTP server requires a secure
> > connection or the client was not authenticated. The server response
> > was: 5.7.0 Must issue a STARTTLS command first e13sm6192679qba.37

>
> > or
> > 2 - when i enable ssl
> > SmtpException has Occured: The SMTP server requires a secure
> > connection or the client was not authenticated. The server response
> > was: 5.5.1 Authentication Required e11sm6169311qbc.5

>
> > who can it be solved ?
> > also who can i use this account to send email through the password
> > recovery control ?
> > thanks


 
Reply With Quote
 
fredd00
Guest
Posts: n/a
 
      02-20-2008
it actually works fine
the error is poped because i'm using the password recovery control,
which doesn't seem to like my network config
i simply cancel the event after sending the email through my email
method

thanks

On Feb 18, 1:31 pm, Peter Bromberg [C# MVP]
<(E-Mail Removed)> wrote:
> Try doing it with a chunky method:
>
> using System;
> using System.Collections.Generic;
> using System.Text;
>
> namespace PAB.SEO
> {
> public static class GmailSender
> {
> public static void SendGmail(string userName, string password,
> string mailFrom,
> string mailTo, string commaDelimCCs, string
> subject, string message, bool isBodyHtml)
> {
> System.Net.Mail.MailMessage msg = new
> System.Net.Mail.MailMessage(mailFrom, mailTo,
> subject, message);
> msg.IsBodyHtml = isBodyHtml;
> if(commaDelimCCs!="")
> msg.CC.Add(commaDelimCCs );
> System.Net.NetworkCredential cred = new
> System.Net.NetworkCredential(userName, password);
> System.Net.Mail.SmtpClient mailClient = new
> System.Net.Mail.SmtpClient("smtp.gmail.com", 587);
> mailClient.EnableSsl = true;
> mailClient.UseDefaultCredentials = false;
> mailClient.Credentials = cred;
> mailClient.Send(msg);
> }
> }
>
> }
>
> --Peter
> Site:http://www.eggheadcafe.com
> UnBlog: htp://petesbloggerama.blogspot.com
> Short Urls & more:http://ittyurl.net
>
> "fredd00" wrote:
> > Hi

>
> > i'm trying to send email through my gmail account, used to work

>
> > web.config

>
> > <system.net>
> > <mailSettings>
> > <smtp from="myfrom" >
> > <network defaultCredentials="true" host="smtp.gmail.com"
> > port="465" userName="mygmailusername" password="mygmailpassword"/>
> > </smtp>
> > </mailSettings>
> > </system.net>

>
> > my fonction

>
> > public static void SendEmail(string To, string From, string Subject,
> > string Body, bool IsBodyHtml)
> > {
> > try
> > {
> > using (MailMessage message = new MailMessage(From, To,
> > Subject, Body))
> > {
> > message.IsBodyHtml = IsBodyHtml;
> > SmtpClient mailClient = new SmtpClient();
> > mailClient.Send(message);
> > }
> > }
> > catch (SmtpException ex)
> > {
> > throw new ApplicationException("SmtpException has
> > Occured: " + ex.Message);
> > }
> > }

>
> > i get either error :
> > 1-
> > SmtpException has Occured: The SMTP server requires a secure
> > connection or the client was not authenticated. The server response
> > was: 5.7.0 Must issue a STARTTLS command first e13sm6192679qba.37

>
> > or
> > 2 - when i enable ssl
> > SmtpException has Occured: The SMTP server requires a secure
> > connection or the client was not authenticated. The server response
> > was: 5.5.1 Authentication Required e11sm6169311qbc.5

>
> > who can it be solved ?
> > also who can i use this account to send email through the password
> > recovery control ?
> > thanks


 
Reply With Quote
 
good_zeus@hotmail.com
Guest
Posts: n/a
 
      08-04-2012
On Monday, February 18, 2008 6:56:03 AM UTC+2, fredd00 wrote:
> Hi
>
> i'm trying to send email through my gmail account, used to work
>
> web.config
>
> <system.net>
> <mailSettings>
> <smtp from="myfrom" >
> <network defaultCredentials="true" host="smtp.gmail.com"
> port="465" userName="mygmailusername" password="mygmailpassword"/>
> </smtp>
> </mailSettings>
> </system.net>
>
> my fonction
>
> public static void SendEmail(string To, string From, string Subject,
> string Body, bool IsBodyHtml)
> {
> try
> {
> using (MailMessage message = new MailMessage(From, To,
> Subject, Body))
> {
> message.IsBodyHtml = IsBodyHtml;
> SmtpClient mailClient = new SmtpClient();
> mailClient.Send(message);
> }
> }
> catch (SmtpException ex)
> {
> throw new ApplicationException("SmtpException has
> Occured: " + ex.Message);
> }
> }
>
> i get either error :
> 1-
> SmtpException has Occured: The SMTP server requires a secure
> connection or the client was not authenticated. The server response
> was: 5.7.0 Must issue a STARTTLS command first e13sm6192679qba.37
>
> or
> 2 - when i enable ssl
> SmtpException has Occured: The SMTP server requires a secure
> connection or the client was not authenticated. The server response
> was: 5.5.1 Authentication Required e11sm6169311qbc.5
>
>
> who can it be solved ?
> also who can i use this account to send email through the password
> recovery control ?
> thanks


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
send SMTP mail using JavaMail with gmail account jrefactors@hotmail.com Java 15 07-11-2012 02:01 PM
website MX record on gmail / send mail from website Gustavo NZ Computing 1 12-21-2011 12:06 AM
using GMail to send e-mail causing email Brian Rhiel Ruby 1 05-31-2010 06:59 PM
Mail component to retrieve mail from Hotmail, Yahoo, gmail..etc? John Dalberg ASP .Net 1 09-19-2005 02:56 PM
gmail blocks .rar files from non-gmail address kritaly Computer Support 3 08-18-2005 12:00 AM



Advertisments