Send Email in Gmail using vb6

Description:A simple function that helps to send an email using your gmail account in vb6 (uses smtp). You can also add attachment files. Copy and Paste the code below:



Replace “username” with your gmail username
Replace “password” with your gmail password
Replace “” with ‘to address’
Replace “MyName” with your name
Advanced Usage:

You can add attachments by adding .Addattachment (replace filename1 and filename2 with your file names).
You can also add cc and bcc address as seen in the code.

Example Usage:


  1. When i run this project an error displayed “The transport failed to connect to the server” i search this error in google but its unanswered

    1. I had this similiar problem. It turns out that power supply went off (i had broadband connection). I think there were no network when you executed the code.

  2. Installing Internet information server may fix the problem. It doesn’t use the local server, but maybe one of the required services needs to be running and isn’t. If still problem persist check whether username and password are correct

  3. I were using this code in my projects, but now I receive several times an error message that says : “Cannot send message to server” .. I tried using it again but sounds Gmail cut the supply on us .. Does anybody know something about that ?

Leave a Reply

Your email address will not be published. Required fields are marked *