CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Mail Sending

  1. #1
    Join Date
    Jun 1999
    Location
    Pune, Maharastra, India
    Posts
    59

    Mail Sending

    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


  2. #2
    Join Date
    Jun 1999
    Location
    virginia
    Posts
    16

    Re: Mail Sending

    VB 5 and 6 comes with a MAPI control. You can find tutorials on the net.


  3. #3

    Re: Mail Sending

    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.


  4. #4
    Guest

    Re: Mail Sending

    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




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured