Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

send mail with gmail

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fredd00 - 18 Feb 2008 04:56 GMT
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
sloan - 18 Feb 2008 05:22 GMT
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.

> Hi
>
[quoted text clipped - 49 lines]
> recovery control ?
> thanks
Peter Bromberg [C# MVP] - 18 Feb 2008 18:31 GMT
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

> Hi
>
[quoted text clipped - 49 lines]
> recovery control ?
> thanks
fredd00 - 20 Feb 2008 04:52 GMT
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]
<pbromb...@yahoo.NoSpamMaam.com> wrote:
> Try doing it with a chunky method:
>
[quoted text clipped - 88 lines]
> > recovery control ?
> > thanks
fredd00 - 20 Feb 2008 05:25 GMT
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]
<pbromb...@yahoo.NoSpamMaam.com> wrote:
> Try doing it with a chunky method:
>
[quoted text clipped - 88 lines]
> > recovery control ?
> > thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.