Free Support Forum - aspose.com

Sending mail through Gmail SMTP using Aspose.Email

Hi,

I am trying to send mail using the SMTP seetings / credentials of Gmail and Aspose.Email in a Windows Application based on Framework 3.5. But when the execution point hits the line "client.Send(mailMsg)" it is taking a very very long time and nothing happens. No mails are sent.

Please let me if it is possible to send mail using Gmail SMTP configuration in Aspose. If yes, please let me know the error in the below code. Thanks.

Dim mailMsg As MailMessage = New MailMessage()
mailMsg.From = "USEREMAIL_OF_GMAIL_ACCOUNT"
mailMsg.To.Add(New MailAddress("XXXXXXXX"))
mailMsg.Subject = "Testing SMTP through Gmail"
mailMsg.Body = "Test Email's body"
Dim client As SmtpClient = New SmtpClient("smtp.gmail.com", 465, "USERNAME_OF_GMAIL_ACCOUNT", "PASSWORD_OF_GMAIL_ACCOUNT")
client.Send(mailMsg)

Regards,

Deivarayan

Hi Deivarayan,


Yes, Aspose.Email does support sending emails through Gmail’s smtp server. For SSL enabled smtp servers, you need to set the SmtpClient properties as shown below:

’ set the port to 587. This is the
SSL port of Gmail SMTP server
<o:p></o:p>

client.Port = 587

' set the security mode to explicit

client.SecurityMode = SmtpSslSecurityMode.Explicit

' enable SSL

client.EnableSsl = True

Please try it at your end and let us know your feedback.

Thanks Kashif.

It is working now.

Hi Deivarayan,


Thanks for the feedback. Its good to know it solved your issue. Please feel free to let us know if you have any further query/inquiry regarding Aspose.Email.