Sending email from Navision

I am using codeunit 397 in my code to send email from Sales Order entry when a certain condition arises. Our client wants the email to be sent to 3 people. I am able to send to two of them by using the first person’s address as the ToName parameter and the second person’s address as the CCName parameter of the NewMessage functon of the codeunit. I tried filling the CCName parameter with two people’s email addresses(2nd and 3rd persons) separated by ; or , but it does not work. I get an email back from System Administrator of Microsoft Outlook with malformed address error. Can someone suggest a way of sending an email to more than 2 people usng the Newmessage function of codeunit 397 ? I can think of one way but it is not a pretty way of doing it. I can call the function NewMessage twice, first sending it to 2 people and then the second time to send it to a third person. Pari Somasundaram.

Give the user a button to e-mail the Sales Order via e-mail. Write a small amount of code to loop through each receipient and call the mail codeunit on each loop, changing the receipient e-mail’s address. I don’t know how big the scope of this project is but, you may also wish to consider writting an internal mail enhancement. We’ve done it here and it works great. We can “attach” most major forms along with the current record to the internal mail. When the receipient receives it, they click on the “attachment” and then the appropriate form and record are displayed for them. Bill Benefiel Manager of Information Systems Overhead Door Company (317) 842-7444 ext 117 Edited by - wbenefiel on 2002 Feb 12 13:55:49

For two “CCs” you simply have to call the same code two times. For example … MAPI.RecipIndex := MAPI.RecipCount; MAPI.RecipType := 2; MAPI.RecipDisplayName := MyMailAdress_1; MAPI.RecipIndex := MAPI.RecipCount; MAPI.RecipType := 2; MAPI.RecipDisplayName := MyMailAdress_2; For every call, the next Address is autom. added with a semikolon. You could also do that in a loop with many adresses.

Damn - William was 30 seconds faster than me … :wink:

In Attain the codeunit 397 now calls a Navision OCX instead on the MSMAPI OCX. I would imagine this is so that the body lines can be built up in the ocx before the mail is sent to overcome the limit on text length. I know this because I have had such problems in the past. As we do not know what is going on in Navisions OCX (not a lot by the looks of it) and you have tried using seperators you have three options. 1) Call the codeunit multiple times. 2) write your own OCX a good starting point for this being Dean Dusenbery’s excellent vbSendMail at 3) write a codeunit to use MSMAPI ocx like the old Navision Mail function but that does not work very well that is why most people write there own ocx. Paul Baxter

You are all too quick today Richard’s idea only works with the MSMAPI OCX not Navision’s so do that if you are using 2.60 or before. Paul Baxter

Thankyou all very much. I have, in fact, used the simpler solution of calling the function multiple times. Pari Somasundaram.

Moved from “Attain/Financials Developer Forum” to “Attain/Financials Developer FAQ”.