Mapi Help

CT Witter

MrExcel MVP
Joined
Jul 7, 2002
Messages
1,212
Using access 2k and outlook express 6 to send emails with attachments. Have tried 2 different methods and didn't have luck with either. The first one (below) works fine but no attachments.

The second example comes from MS KB article 99403 and will go to oe, however, there is no to filled in (it comes back as blank with a ";")

I've see some other vb articles but nothing that has worked in access. I imagine that i have to use the msoe.dll (the other ones, mapi.dll, or mapi32.dll don't seem to work).

Also, since i don't have the mapi controls that come with vb...i can't use those solutions
Please help.

Vetter


Code:
Option Explicit

Type MAPIRecip
    Reserved As Long
    RecipClass As Long
    Name As String
    Address As String
    EIDSize As Long
    EntryID As String
End Type

Type MAPIFileTag
    Reserved As Long
    TagLength As Long
    Tag() As Byte
    EncodingLength As Long
    Encoding() As Byte
End Type

Type MAPIFile
    Reserved As Long
    Flags As Long
    Position As Long
    PathName As String
    FileName As String
    FileType As MAPIFileTag
End Type

Type MAPIMessage
    Reserved As Long
    Subject As String
    NoteText As String
    MessageType As String
    DateReceived As String
    ConversationID As String
    Originator As Long
    Flags As Long
    RecipCount As Long
    Recipients As Long
    Files As Long
    FileCount As Long
End Type

Declare Function MAPISendMail _
    Lib "c:\program files\outlook express\msoe.dll" ( _
    ByVal Session As Long, _
    ByVal UIParam As Long, _
    message As MAPIMessage, _
    ByVal Flags As Long, _
    ByVal Reserved As Long) As Long

Sub SendMailWithOE(ByVal strSubject As String, ByVal strMessage As String, ByRef 
aRecips As Variant)
    Dim recips() As MAPIRecip
    Dim message As MAPIMessage
    Dim z As Long
    ReDim recips(LBound(aRecips) To UBound(aRecips))
    For z = LBound(aRecips) To UBound(aRecips)
        With recips(z)
            .RecipClass = 1
            If InStr(aRecips(z), "@") <> 0 Then
                .Address = StrConv(aRecips(z), vbFromUnicode)
            Else
                .Name = StrConv(aRecips(z), vbFromUnicode)
            End If
        End With
    Next z
    With message
        .NoteText = strMessage
        .Subject = strSubject
        .RecipCount = UBound(recips) - LBound(aRecips) + 1
        .Recipients = VarPtr(recips(LBound(recips)))
    End With
    MAPISendMail 0, 0, message, 0, 0
End Sub

Sub TestSendMailwithOE()
    Dim aRecips(0 To 0) As String
    aRecips(0) = "smtp:tomvs@syspac.com"
    SendMailWithOE "Send Mail Through OE", "Sure, you can, Tom!", aRecips
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,221,517
Messages
6,160,264
Members
451,635
Latest member
nithchun

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top