EldoS | Feel safer!

Software components for data protection, secure storage and transfer

gmail send mail problemm

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
Posted: 04/12/2010 12:00:25
by Levan Sopromadze (Basic support level)
Joined: 02/16/2010
Posts: 5

Hi all, I wrote application to send emails. I used smtpClient to do this, It's working, but if I changed email with gmail smtp settings, I can't send mail.
I tried to use 465 port instead of 25, but without result.
This is my code:

public string mailHost = "smtp.gmail.com";
public string mailUser = "***********@googlemail.com";
public string mailPass = "**********";



            SBSimpleMIME.TElSimpleMIMEMessage mailMessage = new SBSimpleMIME.TElSimpleMIMEMessage();
            SBSMTPClient.TElSMTPClient smtpClient = new SBSMTPClient.TElSMTPClient();
            SBSimpleMIME.TElSimpleMIMEAttachment attachement = new SBSimpleMIME.TElSimpleMIMEAttachment();

            smtpClient.Address = mailHost;
            smtpClient.Username = mailUser;
            smtpClient.Password = mailPass;            
            smtpClient.Port = 465;
            //smtpClient.Port = 25;

            mailMessage.Subject = mailSubj;
            mailMessage.From = mailFrom;
            mailMessage.BodyPlain.Text = mailText;

            // Adding attachment
            int idx = mailMessage.AddAttachment();
            if (idx != -1)
                attachement = mailMessage.get_Attachments(idx);
                attachement.ContentStream = new FileStream(filename, FileMode.Open);
                attachement.ContentType = "image/bmp";
                attachement.Name = mailAttachName;

                Result("Sent Successfuly");
            catch (Exception ex)

Please help me if you can...
Posted: 04/12/2010 12:19:33
by Eugene Mayevski (EldoS Corp.)

Port 465 expects implicit TLS and I don't see that you have enabled it for smtpClient in your code.

Sincerely yours
Eugene Mayevski
Posted: 04/12/2010 12:39:24
by Levan Sopromadze (Basic support level)
Joined: 02/16/2010
Posts: 5

I changed my code:
smtpClient.Address = mailHost;
            smtpClient.Username = mailUser;
            smtpClient.Password = mailPass;
            smtpClient.UseSSL = true;
            smtpClient.Port = 465;
            smtpClient.SSLMode = SBSMTPClient.TSBSSLMode.smImplicit;
            smtpClient.UseInternalSocket = true;            

But I got error: "Certificate validation handler is not assigned".
I found this at forum:
smtpClient.OnCertificateValidate += new SBSSLCommon.TSBCertificateValidateEvent(client_OnCertificateValidate);
smtpClient.OnError += new SBSSLCommon.TSBErrorEvent(client_OnError);

But I can't understood how "client_OnCertificateValidate" works and how I can use it, maybe you can explain me ?
Posted: 04/12/2010 23:20:17
by Ken Ivanov (EldoS Corp.)

Certificate validation basics are are explained here. You can also use TElX509CertificateValidator component that will do most of the work explained there for you.



Topic viewed 1275 times

Number of guests: 2, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!