How to send mail using MAPISession & MAPIMessages?

Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
I need NAV to generate mails with more than one attachment, that's why I try to send mails using the MAPISession & MAPIMessages OCX.

When this code is executed, the error "The call to member Send failed. MAPIMessages returned the following message: Unspecified Failure has occurred" is displayed:
variables used:
ocxMAPISession     OCX   Microsoft MAPI Session Control, version 6.0
ocxMAPIMessages    OCX   Microsoft MAPI Messages Control, version 6.0

ocxMAPISession.SignOn;
ocxMAPIMessages.SessionID := ocxMAPISession.SessionID;
ocxMAPIMessages.Compose;
ocxMAPIMessages.RecipAddress := 'email@address.com';
ocxMAPIMessages.MsgSubject := 'Subject of mail';
ocxMAPIMessages.MsgNoteText := 'Body of mail';
ocxMAPIMessages.Send;
ocxMAPISession.SignOff;
Does anyone has a clue, why this example cannot be executed correctly? ](*,)
Outlook 2007 is used BTW.
No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I found a way to send mails, using automation ('Microsoft Outlook 12.0 Object Library'.MailItem).

    It would be interested to know though, why the code from my previous posting isn't working. :-k
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • mdPartnerNLmdPartnerNL Member Posts: 802
    I know it's an old topic. But why is everybody using codeunit 397 for sending email. Why not do it with ('Microsoft Outlook 12.0 Object Library'.MailItem).
Sign In or Register to comment.