ranjit
October 17th, 1999, 07:59 AM
How to send E-Mails from a vb program ,do i do it using outlook , are there any other settings to be done to send mails from a vb program
|
Click to See Complete Forum and Search --> : Mail Sending ranjit October 17th, 1999, 07:59 AM How to send E-Mails from a vb program ,do i do it using outlook , are there any other settings to be done to send mails from a vb program wayne October 17th, 1999, 08:12 AM VB 5 and 6 comes with a MAPI control. You can find tutorials on the net. czimmerman October 18th, 1999, 02:07 PM See http://www.freevbcode.com/ShowCode.Asp?ID=109. This is a .dll that handles e-mails in VB. It will help you avoid the various headaches associated with MAPI. November 12th, 1999, 06:07 PM If you have Outlook installed, an easy way is to create a class module called cOutlook like below. Then, you can somewhere else declare it Public Mailer as New cOutlook and then use the Mailer.SendMail (.....) method to send email. If you have to use MAPI, then use the .dll the other guy recommends. Option Explicit Private Outlook As New Outlook.Application Private mblnTerminateOutlook As Boolean Private Sub Class_Initialize() mblnTerminateOutlook = Outlook.ActiveExplorer Is Nothing End Sub Private Sub Class_Terminate() If mblnTerminateOutlook Then Outlook.Quit Set Outlook = Nothing End Sub Public Sub SendMail(strTo As String, strSubject As String, _ strMessageText As String, Optional strCC As String, _ Optional vntAttachmentPath As Variant) Dim i As Integer With Outlook With .CreateItem(olMailItem) .To = strTo .CC = strCC .Subject = strSubject .Body = strMessageText & vbCrLf & vbCrLf If IsArray(vntAttachmentPath) Then For i = 0 To UBound(vntAttachmentPath) .Attachments.Add vntAttachmentPath(i), , Len(.Body) Next i End If .Send End With End With End Sub codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |