Tuesday, November 07, 2006

How to send email through a VB application ?

Article on freevbcode
vbSendMail.dll Version 3.65-- Easy E-mail Sending in VB, with Attachments

Sending an e-mail with this .dll is as simple as the following:

'Module Level Declaration (WithEvents optional but recommended)
Private WithEvents poSendMail as vbSendMail.clsSendMail
Private Sub cmdSend_Click()
'Assumes you have a form with text boxes named as below

set poSendMail = new vbSendMail.clsSendMail
poSendMail.SMTPHost = txtServer.Text
poSendMail.From = txtFrom.Text
poSendMail.FromDisplayName = txtFromName.Text
poSendMail.Recipient = txtTo.Text
poSendMail.RecipientDisplayName = txtToName.Text
poSendMail.ReplyToAddress = txtFrom.Text
poSendMail.Subject = txtSubject.Text
poSendMail.Attachment = txtFileName.text 'attached file name
poSendMail.Message = txtMsg.Text
poSendMail.Send
set poSendMail = nothing
End Sub

For multiple file attachments, an example would be:

poSendMail.Attachment = txtFileName1.text & ";" & txtFileName2.text

No comments:

Digg it !