E-mail creation with MAPI

Eddie
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??
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??
0
Comments
-
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."0 -
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); // send0 -
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."0 -
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 Giebens0 -
BGI:
You have got right... but this source code doesn't allow you send more than 1 attachment file per e-mail.0 -
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 Giebens0 -
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions