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

Thread: Sending a Mail

  1. #1
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    25

    Sending a Mail

    Hi - does anyone know how I'd send a mail using VB6? Is there a control, or do I've to go into MAPI?

    Any help would be greatly appreciated!


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Sending a Mail

    you can add the "microsoft MAPI controls" to your project via Project/components.
    Use the MAPI Session control to establish a MAPI session, use the MAPI messages control to read or send messages.


  3. #3

    Re: Sending a Mail

    See http://www.freevbcode.com/ShowCode.Asp?ID=109 for a .dll that allows you to do this. It will save you the headaches of MAPI.


  4. #4
    Guest

    Re: Sending a Mail

    How to include the Mapi control in VB6...it's saying
    error in loading dll when i try to include the Mapiformobject type library...





  5. #5
    Join Date
    Oct 1999
    Posts
    21

    Re: Sending a Mail

    Go to options, go to references in the avaliable references you will find Common Dialog you wil find the control added on your controls panel go ahead and select it.

    Garry


  6. #6
    Guest

    Re: Sending a Mail

    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