Outlook E-Mail Body

Hi all! I want to create an Outlook e-Mail by using Outlook Automation. There, I want to create a new line in the body for e.g. every Purchase Order Line, like OlMail.Body := OlMail.Body + OrderLine + FORMAT(LF); But when I try to add more than two or threee lines I receive that ERROR

quote:

The length of the text string exceeds the size of the string buffer.

Obviously, there is limit of characters when using Automation, manually I can insert as many lines as i want - of course! Any advice how to bypass this limit? Am I doing something wrong? Thanx in advance! Jörg

I tried to do the same with NF 2.60 and Office XP. Maximum was 256 chars for subject and body :frowning: I didn’t find any solution.

Some time ago I ran into the same problem, albeit in a different environment (not C/AL that is). I created a wrapper for the Outlook Object with 1 additional method “AddStringToBodyText” which accepted a 255 byte Pascal String and added that to the message body. The other parameter for the method (aside from the string to be attached) was a switch to include a CRLF after the string or not. Tedious work, you have to copy every Outlook method you need in the wrapper, but if you absolutely need it - it’s possible. Used C++ for the wrapper, but VB6 is fine as well. And of course, whenever a new version of the Outlook Object is released, you’ll have to check your wrapper for compatibility. Hope this helps you a bit Unfortunately no code anymore of that - lost in history…

You could use the Mapi-Handler which comes with attain (NsAppHandler.dll). simple Example: Variable: MapiHandler → Automation → ‘Navision Attain ApplicationHandler’.MAPIHandler Code: CREATE(MapiHandler); MapiHandler.ToName := ZuName; MapiHandler.CCName := CCName; MapiHandler.Subject := Subjekt; MapiHandler.Body := Body MapiHandler.AttachFileName := DateiName; IF Emailtext.FIND(’-’) THEN BEGIN REPEAT MapiHandler.AddBodyText(Emailtext.Bemerkung); UNTIL Emailtext.NEXT = 0; END; MapiHandler.OpenDialog := true; MapiHandler.Send; IF (MapiHandler.ErrorStatus <> 0) then begin ERROR(FORMAT(MapiHandler.ErrorStatus)+’: ’ + MapiHandler.ErrorDescription); END;

Thanx to all, especially Uwe: MAPI was the trick! Now it’s running perfectly [:D] Regards, Jörg