Attachments using MAPI comtrol

I have an app I developed with VB 6.0 using the MAPI control. What I am trying to do is attach a document or file to an email that will be created from the app. I am lost on how to do this andy help would be appreciated. I also want to know how to send the mail message to mutiple persons(I.E a group or mutiple individuals, CC, BCC) I am using Outlook as my mail client.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tmcak, just try like this
hope this helps

Private Sub Command1_Click()
    ' this command button is used to start a MAPI session, log on the
    '     the
    ' mail service, attach the created check summary text file to a n
    '     ew
    ' message, send the message and then close the session
    ' declare local variables here
    Dim strUserId As String
    Dim strPassword As String
    Dim strFileName As String
    Dim strFilePath As String
    ' set the mouse pointer to indicate the app is busy
    Screen.MousePointer = vbHourglass
    ' set the values for the file name and the file path
    strFileName = "sendmail.frm" ' this is where you would put any file attachments
    strFilePath = App.Path & "\"
    ' set the user name and password properties on the session contro
    '     l
    mapiLogOn.UserName = "user" ' network user name and password !
    mapiLogOn.Password = "testing"
    ' start a new email session

    Do While mapiLogOn.SessionID = 0

        DoEvents ' need to wait until the new session is created

        'create a new message and address it
        MAPIMessages1.SessionID = mapiLogOn.SessionID
        MAPIMessages1.RecipDisplayName = "Danny Setiawan"
        MAPIMessages1.AddressResolveUI = True
        MAPIMessages1.RecipAddress = ""
        ' note that I prefixed the address with "smtp". This is required
        '     by exchange
        ' server, or it does not know what service to use for outgoing ma
        '     il.
        MAPIMessages1.MsgSubject = "Test of the Email function"
        MAPIMessages1.MsgNoteText = " This is a test of the email function, If you" _
        & "receive this Then the program has worked successfully." & vbCrLf
        ' attaching the file
        MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) - 1
        ' the line above places the attachment at the end of the text.
        MAPIMessages1.AttachmentPathName = strFilePath & strFileName
        ' now send the message
        MAPIMessages1.Send False
        MsgBox "File sent to specified receiptent."
        ' now set the mouse pointer back to normal
        Screen.MousePointer = vbNormal
End Sub

note : mapiLogOn is same as MAPISession1 ( rename   MAPISession1 to mapiLogOn

tmackAuthor Commented:
This is great! Sorry I rejected your answer but I wanted to ask for a one
last thing(and I am adjusting points for this). I would also like to know
how I can send to more than one person. For example if I wanted to send to
Tom, Dick, and Harry. I have tried to do this several times(delimiting the
addresses with ';' but this doesnt work) but with out success. Also is there
a way if I just created a 'group' in outlook could I just call this and send
my message to those recipients? If you could just set me on the right path I
would appreciated it.
Tmack, I haven't try it and have no time to try it but It should be work

Const RECIPTYPE_TO = 1      
Const RECIPTYPE_CC = 2  
MapiMessages1.RecipIndex = 0                    'First recipient
      MapiMessages1.RecipType = RECIPTYPE_TO          'Recipient in TO line
      MapiMessages1.RecipDisplayName = "Tom"   'e-mail name
      MapiMessages1.RecipIndex = 1                  'add a second recipient
      MapiMessages1.RecipType = RECIPTYPE_TO        'Recipient in TO line
      MapiMessages1.RecipDisplayName = "Dick"     'e-mail name
      MapiMessages1.RecipIndex = 2                   'Add a third recipient
      MapiMessages1.RecipType = RECIPTYPE_CC         'Recipient in CC line
      MapiMessages1.RecipDisplayName = "BlairAngelHair"  'e-mail name
      MapiMessages1.RecipIndex = 3                  'Add a fourth recipient
      MapiMessages1.RecipType = RECIPTYPE_CC          'Recipient on CC Line
      MapiMessages1.RecipDisplayName = "Harry" 'e-mail name"
tmackAuthor Commented:
I will test this and get back to ya, thanks again.....

tmack just foolow this and you will be happy!

Considering following things

0) You are all set with the MAPISession1 and MAPIMessage1
1) MAPIMessison1.MsgIndex = -1  'Must set to -1 if you are composing message
2) ToList = collection of the e-mail addresses of the To:, you can heve arrays to
3) CcList = collection of the e-mail addresses of the Cc: you can heve arrays to
4) BccList = collection of the e-mail addresses of the Bcc: you can heve arrays to
5) AttachList = collection of the full path of the files to be attached

    rcptEntryIndex = 0
    For Each toEntry In ToList
        If (toEntry <> "") Then
            MAPIMessage1.RecipIndex = rcptEntryIndex
            MAPIMessage1.RecipAddress = CStr(toEntry)
            MAPIMessage1.Action = vbMessageResolveName
            MAPIMessage1.RecipType = 1 'mapToList
            rcptEntryIndex = rcptEntryIndex + 1
        End If
    Next toEntry
    For Each ccEntry In CcList
        If (ccEntry <> "") Then
            MAPIMessage1.RecipIndex = rcptEntryIndex
            MAPIMessage1.RecipAddress = CStr(ccEntry)
            MAPIMessage1.Action = vbMessageResolveName
            MAPIMessage1.RecipType = 2 'mapCcList
            rcptEntryIndex = rcptEntryIndex + 1
        End If
    Next ccEntry
    For Each bccEntry In BccList
        If (bccEntry <> "") Then
            MAPIMessage1.RecipIndex = rcptEntryIndex
            MAPIMessage1.RecipAddress = CStr(bccEntry)
            MAPIMessage1.Action = vbMessageResolveName
            MAPIMessage1.RecipType = 3 'mapBccList
            rcptEntryIndex = rcptEntryIndex + 1
        End If
    Next bccEntry

    attachEntryIndex = 0
    For Each attachEntry In AttachList
        If (Dir(attachEntry) <> "") Then
            MAPIMessage1.AttachmentIndex = attachEntryIndex
            MAPIMessage1.AttachmentType = 0 'mapData 'look for other const in the help file
            MAPIMessage1.AttachmentName = ""
            ' position must be at the end of the message body - 1, read the help file
            MAPIMessage1.AttachmentPosition = Len(MAPIMessage1.MsgNoteText) - 1
            MAPIMessage1.AttachmentPathName = CStr(attachEntry)
            attachEntryIndex = attachEntryIndex + 1
        End If
    Next attachEntry
    MAPIMessage1.Action = 3 'send without showing the dialog
                            'that is direct send


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.