Page view counter

Please Help! Sending email

Last post 06-03-2008 11:50 AM by pixelsyndicate. 3 replies.

Sort Posts:

  • Please Help! Sending email

    06-03-2008, 10:35 AM
    • Loading...
    • jornjae
    • Joined on 05-31-2008, 4:29 AM
    • Posts 42
    • Points 13

    I'd like to send email from my ecommerce web by using a Gmail but I don't know how to modify the code(I didn't write it myself). Thanks for your help.

    This's the code :
      
     // Generic method for sending emails
        public static void SendMail(string from, string to, string subject, string body)
        {
            // Configure mail client (may need additional code for authenticated SMTP servers)
            SmtpClient mailClient = new SmtpClient(ABCConfiguration.MailServer);
            NetworkCredential nc = new NetworkCredential("abc@gmail.com", "1234");
            mailClient.Credentials = nc;
            // Create the mail message
            MailMessage mailMessage = new MailMessage("abc@gmail.com", to, subject, body);
            // Send mail
            mailClient.Send(mailMessage);
        }

    In web.config

     <add key="MailServer" value="smtp.gmail.com " /> 

    This's gmail configuration :

    Incoming Mail (POP3) Server - requires SSL: pop.gmail.com
    Use SSL: Yes
    Port: 995 
    Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
    Use Authentication: Yes
    Use STARTTLS: Yes (some clients call this SSL)
    Port: 465 or 587 

  • Re: Help Me! Sending email

    06-03-2008, 10:41 AM
    • Loading...
    • pixelsyndicate
    • Joined on 07-04-2003, 8:56 AM
    • W. MI transplant in N. TX
    • Posts 1,082
    • Points 6,012

    you may need to make some more settings changes to your mailClient object, based on what I see in your gmail configuration (SSL and PORT)

     

                mailClient.Port = 995;
                mailClient.EnableSsl = true;

    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

    http://pixelsyndicate.com/ps/
  • Re: Help Me! Sending email

    06-03-2008, 11:17 AM
    • Loading...
    • jornjae
    • Joined on 05-31-2008, 4:29 AM
    • Posts 42
    • Points 13

    Thanks for your advise and I modified the code as what you told me. Unfortunately, I've got this error. Could you tell me how to fix it out?

  • Re: Help Me! Sending email

    06-03-2008, 11:50 AM
    Answer
    • Loading...
    • pixelsyndicate
    • Joined on 07-04-2003, 8:56 AM
    • W. MI transplant in N. TX
    • Posts 1,082
    • Points 6,012

    from all the research i have done for this issue, the problem is that the connection isn't actually opening. Some searches I have done suggest that the particular port you are using might be closed off at the OS or the Firewall.  Also, the mailClient.Credentials might need something extra beyond a username/password. perhaps you can only READ emails from the GMAIL SMTP server and not actually send through this type of transport.  It's hard to say since I generally use my ISP host's SMTP server to send email (some block sending though a network not of their making, like Charter communications, to prevent people using their service as SPAM machines).

    are you building a spam machine? Big Smile

    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

    http://pixelsyndicate.com/ps/
Page 1 of 1 (4 items)