How to Send an Email via G-Mail in Visual Basic 6

How to Send an Email via G-Mail in Visual Basic 6 thumbnail
Google Gmail only accepts email requests through a secure SSL connection.

Visual Basic 6 (VB6) is Microsoft's take on the classic Basic computer programming language. The VB6 version of the language and the IDE program used to create software was the last version released by Microsoft before the .NET version. Software developers use Visual Basic 6 to create a wide variety of desktop applications for the Windows platform. Developers can even add functionality to send email through a Google Gmail account.

Instructions

    • 1

      Open Visual Basic 6. VB6 comes as a standalone application or part of the Visual Studio 6. If you have the standalone version, you can double-click on the VB6 icon on your desktop or click "Start," "All Programs," "Microsoft Visual Basic 6" and then "Visual Basic 6" to open the program. For the Studio, click on the icon to open the Visual Studio 6. Click the "Visual Basic" tab on the welcome screen and then choose to open an existing Visual Basic project or to start a new one.

    • 2

      Click on "View" and then "Code" to switch to code view. Add a procedure that will send an email through a Gmail account:

      "Sub SendGmail()

      Set emailMsg = CreateObject("CDO.Message")

      Set config = CreateObject("CDO.Configuration")

      Set emailFields = config.Fields

      sch= "http://schemas.Microsoft.com/cdo/configuration/"

      emailFields.Item(sch & "sendusing") = 2

      emailFields.Item(sch & "smtpserver") = "smtp.gmail.com"

      emailFields.Item(sch & "smtpserverport") = 465

      emailFields.Item(sch & "smtpauthenticate") = 1

      'change the following line to your gmail email address

      emailFields.Item(sch & "sendusername") = myemailaddress@gmail.com

      'use the password you use to log into your gmail email account

      emailFields.Item(sch & "sendpassword") = mypassword

      emailFields.Item(sch & "smtpusessl") = 1

      emailsFields.Update

      With emailMsg

      .To = To 'change this to the recipient(s) of the email

      .From = myemailaddress@gmail.com 'change this to your email address

      .Subject = "Sending an email with Gmail and VB6" 'change to your subject line

      .HTMLBody = "This is a test." 'change this to the body of the email

      Set .Configuration = config

      .Send

      End With

      'clearing everything out for next email

      Set emailMsg = Nothing

      Set config = Nothing

      Set emailFields = Nothing

      End Sub"

    • 3

      Change the portion of the code that asks for your specifics, such as your Gmail email address and password. The items that you need to change is commented out; meaning it starts with an apostrophe (').

    • 4

      Click on the "Save" icon in the toolbar to save changes to the VB6 project.

Related Searches:

References

  • Photo Credit Jason Reed/Photodisc/Getty Images

Comments

Related Ads

Featured