Options

E-mail creation with MAPI

EddieEddie Member Posts: 26
I've got a problem with e-mail creating.
First at all, for creating an e-mail I don't use CodeUnit397, I use my own one based on Microsoft MAPI Messages Control, version 6.0 &
Microsoft MAPI Session Control, version 6.0
The problem appear when the e-mail is allready created with program code and I'm gonna decide if it has to be sent or just showed on the Outlook window as new e-mail.

It can be provided by code:

IF OpenDialog THEN
MAPImessages.Action(2) // Open window
ELSE
MAPImessages.Action(3); // Send direcly

Now the proble....
If I show the Outlook window and doesn't send the mail, just close the window, ERROR message is generated in Navision like that: "User cancelled process". I think it is because Oulook is opened modally and MAPImessages.Action(2) gives back this error message.
So... Is it possible to do something??

Comments

  • Options
    eromeineromein Member Posts: 589
    Why not use Navision standard?

    And could you post more (all) code?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    EddieEddie Member Posts: 26
    I don't use Navision standard because I need add more than 1 attachment file and more than 1 recipient.
    The source code is:

    NoOfAttachment := 0;
    NoOfRecipients := 0;
    MAPISession.DownLoadMail := FALSE;
    IF MAPISession.SessionID = 0 THEN
    MAPISession.SignOn;
    MAPImessages.SessionID := MAPISession.SessionID;
    MAPImessages.Compose;

    MAPImessages.RecipIndex := NoOfRecipients;
    MAPImessages.RecipType := 1;
    MAPImessages.RecipDisplayName := ToName;

    IF Buffer.FIND('-') THEN
    REPEAT
    MAPImessages.AttachmentIndex := NoOfAttachment;
    MAPImessages.AttachmentType := 0;
    MAPImessages.AttachmentPathName := AttachFileName;
    NoOfAttachment := NoOfAttachment + 1;
    UNTIL Buffer.NEXT = 0;


    IF OpenDialog THEN
    MAPImessages.Action(2) // open window
    ELSE
    MAPImessages.Action(3); // send
  • Options
    eromeineromein Member Posts: 589
    I don't know man... But if I would have to make a quess, I would try to find another command to send the mail instead of the action methode. Just like standard Navision is using the OpenDialog methode instead of the action methode.

    I could be completely wrong, but maybe you could give it a shot.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    BGIBGI Member Posts: 176
    Use mapi automation, there you can catch the errors:

    IF ISCLEAR(aut_MAPIHandler) THEN
    CREATE(aut_MAPIHandler);
    int_ErrorNo := 0;
    aut_MAPIHandler.ToName := 'someone@somecompany.com';
    aut_MAPIHandler.Subject := 'something'
    aut_MAPIHandler.AddBodyText('something else');
    aut_MAPIHandler.OpenDialog := TRUE;
    aut_MAPIHandler.Send;
    int_ErrorNo := aut_MAPIHandler.ErrorStatus;
    IF int_ErrorNo <> 0 THEN error('error occured');
    Rgds
    Benny Giebens
  • Options
    EddieEddie Member Posts: 26
    BGI:
    You have got right... but this source code doesn't allow you send more than 1 attachment file per e-mail.
  • Options
    BGIBGI Member Posts: 176
    Aha, that's the catch...

    If you use automation, you have very nice formatted body text with more than 1025 chars, but only 1 attachment

    If you use the other way, you have multiple attachments, but very limited ways of formatting your body tekst and limited chars...

    If navision could be so kind to put both nice things in ONE method... we wouldn't complain anymore (for the mapi things... al the other things... \:D/
    Rgds
    Benny Giebens
  • Options
    EddieEddie Member Posts: 26
    BGi:
    I don't need use the body text. Everything what I need is:
    -generate more then 1 recipient per 1 e-mail
    -generate more then 1 attachment file per 1 e-mail

    Standard codeunit397 doesn't allow this. This is a reason why I have to use
    Microsoft MAPI Messages Control, version 6.0 and
    Microsoft MAPI Session Control, version 6.0

    But with this metode I've got the problem described couple of messages before.
Sign In or Register to comment.