Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use external smtp to send email using vb6 .exe prog?

Status
Not open for further replies.

keith23

Technical User
May 26, 2005
97
NL
Hi all. I got the code beleow that supposed to use external smtp to send email.But i do not know how to use it in visual studio 6.could and expert tell me how to use this code in visual studio version 6? I am new to vb so i be happy if u tell me the steps to use this code and make .exe file and on a click of a button it sends the email and shows a confirmation massge.Thanks
Code:
Set myMail=CreateObject("CDO.Message") 
myMail.Subject="Sending email with CDO" 
myMail.From="mymail@mydomain.com" 
myMail.To="chauth@gmail.com" 
myMail.TextBody="This is a message." 
myMail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")=2[/URL] 
myMail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1[/URL] 
myMail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusername")="youraccount@gmail.com"[/URL] 
myMail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")="yourpassword"[/URL] 
myMail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")=465[/URL] 
myMail.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpusessl")=true[/URL] 
myMail.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com"[/URL] 
myMail.Configuration.Fields.Update 
myMail.Send 
set myMail=nothing
 
Make a reference in your code to Microsoft CDO Library. Then change all of your settings to your personal settings (username/password/server port/etc/etc).

If you're just testing, I'd put the code in a button click event, then play around with it.

As long as your server port (typically 25), your username and password are correct, you should get an e-mail.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top