Search Tools Links Login

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.

Original Author: Prafull Gupta

Code

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 = "abc@gmail.com"

.From = "test@gmail.com"

.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


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 159 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.