Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple file attachment failure with MAPI mail in access

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
When I use VBAMAP32.DLL in my access application for mail I find that I can send only one attachment.

If I make tMessage.FileCount = 1 the message is sent OK with one attachment.

If I make tMessage.FileCount = 2 the message is not sent and I get error 11.
"MAPI Attachment not found".

Here is the code :-

Dim iStatus As Long
Dim gMAPISession As Long
Dim tMessage As MapiMessage
Dim tRecip As MapiRecip
Dim tFiles(2) As MapiFile

'first, logon to MAPI
iStatus = MAPILogon(0&, "", "", MAPI_LOGON_UI, 0&, gMAPISession)
If iStatus <> SUccESS_SUccESS Then
MsgBox MapiErr (iStatus)
Exit Sub
End If

'fill in the structures as needed

tRecip.RecipClass = MAPI_TO
tRecip.Name = &quot;ovajay@usa.net&quot;
tMessage.RecipCount = 1 'one receip
tMessage.FileCount = 2 '2 files
tMessage.Subject = &quot;Test of MAPI&quot;
tMessage.NoteText = Space(2) & vbNewLine & &quot;Hello There&quot;

'set up attachments

tFiles(0).Reserved = 0&
tFiles(0).Flags = 0
tFiles(0).Position = 1
tFiles(0).PathName = &quot;C:\AUTOEXEC.BAT&quot;
tFiles(1).Reserved = 0&
tFiles(1).Flags = 0
tFiles(1).Position = 2
tFiles(1).PathName = &quot;C:\config.sys&quot;

'send message
iStatus = MAPISendMail(gMAPISession, 0&, tMessage, tRecip, tFiles(0),
MAPI_LOGON_UI, 0&)
If iStatus <> SUccESS_SUccESS Then
MsgBox MapiErr(iStatus)
Exit Sub
End If

'logoff of mail, release our session
iStatus = MAPILogoff(gMAPISession, 0, 0, 0)

MsgBox &quot;Mail Successfully Sent&quot;
End Sub

Can you help me please ?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top