Search Tools Links Login

Send email using Visual Basic6.0


Visual Basic 6, or VB Classic

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: 182 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.