VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Send email using Visual Basic6.0

by Prafull Gupta (1 Submission)
Category: Complete Applications
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

This article describes how to pro grammatically send an e-mail message from Visual Basic by using the Collaboration Data Objects (CDO 1.x) Libraries. This example need the CDO 1.x was correctly installed on your computer.

Rate Send email using Visual Basic6.0

Send Email using Visual Basic6.0


This article describes how to pro grammatically send an e-mail message from Visual Basic by using the Collaboration Data Objects (CDO 1.x) Libraries. This example need the CDO 1.x was correctly installed on your computer. You can create programmable messaging objects, and then use their properties and methods to meet the needs of your application.
The sample code can be used from Visual Basic for Applications (VBA), Project to send e-mail messages through the CDO 1.x Library.




Dim file As String

‘ App.path takes the application path and after that user have to provide the file name like as in given code.


file = App.Path & “filename.ext” 


‘For creating new Message object


Dim iMsg As New CDO.Message 

Dim iDsrc As CDO.IDataSource 

Set iDsrc = iMsg ' (QueryInterface)

Dim iConf As New CDO.Configuration 

Dim Flds As Variant

Set Flds = iConf.Fields

With Flds

.Item(cdoSendUsingMethod) = cdoSendUsingPort

.Item(cdoSMTPServer) = "smtp.gmail.com" 
'"smtp.myServer.com"


.Item(cdoSMTPServerPort) = "25"  ‘port no 

.Item(cdoSMTPConnectionTimeout) = 1000 ' quick timeout


.Item(cdoSMTPAuthenticate) = cdoBasic 

.Item(cdoSMTPUseSSL) = True 

.Item(cdoSendUserName) = "abc" ‘”username” 

.Item(cdoSendPassword) = "***" ‘”password” 

.Update 

End With 

With iMsg 

Set .Configuration = iConf 

.To = "[email protected]

.From = "[email protected]

.Subject = "Test” ‘write the subject line here for your mail


.TextBody = "This is the test body” ‘write the body part here


.AddAttachment file ‘used for attachement.You can attach as many files


.send


End With


Download this snippet    Add to My Saved Code

Send email using Visual Basic6.0 Comments

No comments have been posted about Send email using Visual Basic6.0. Why not be the first to post a comment about Send email using Visual Basic6.0.

Post your comment

Subject:
Message:
0/1000 characters