Mail codeunit

Hello, Has anyone tryed to modify the codeunit “mail” to create an unlimited bodylength mail I tryed to modify the codeunit by passing arrays → didn’t work ! Then i tryed with an automation codeunit but it won’t work eather : everytime it exceed 250 chars i receive an internal error 11 in module 45 This is my code : CREATE(Outlook); mail := Outlook.CreateItem(0); mail.Subject := pSubject; mail.“To” := pToName; IF pRecBody.FIND(’-’) THEN REPEAT mail.Body := mail.Body + pRecbody.Text ; UNTIL pRecBody.NEXT < 1; mail.Send; Has anyone ever dealed with this ? Greetings

I’ve succesfully created emails to print emails directly Navision to all NOLUG members. It requires you to create a copy of the Email function Vars: Name DataType Subtype Length CRLF Text 2 CR Char LF Char MAPIMessages OCX Microsoft MAPI Messages Control, version 5.0 MAPISession OCX Microsoft MAPI Session Control, version 5.0

 
CR := 13;
LF := 10;
CRLF := FORMAT(CR) + FORMAT(LF);

MAPISession.DownLoadMail := FALSE;
IF MAPISession.SessionID = 0 THEN
    MAPISession.SignOn;
MAPIMessages.SessionID := MAPISession.SessionID;
MAPIMessages.Compose;
MAPIMessages.RecipIndex := MAPIMessages.RecipCount;
MAPIMessages.RecipType := 1;
MAPIMessages.RecipDisplayName := EmailAddr;

MAPIMessages.MsgSubject := 'NOLUG is running again!';

MAPIMessages.MsgNoteText :=
        'Dear NOLUG member,' + CRLF + CRLF +
        'It has been a long time now where NOLUG has been on low energy.' + CRLF +
        'Since our mailing list was closed down two years ago the web site has been holding' + CRLF +
        'a very simple and not very good user forum. This was only intended to be a temporary' + CRLF +
        'setup while a new and much better site was designed. ' + CRLF + CRLF +
        'The problem was the we wanted too much and that took too much time to create.' + CRLF +
        'Remember that we all has our jobs and that we try to do this in our sparetime.' + CRLF + CRLF +
        'Our website http://www.navision.net is now hosting several user forums that are open' + CRLF +
        'to the public. The idea is that there will be some forums for members only. We will' + CRLF +
        'also add download, links and job sections. But for now please check it out.' + CRLF +
        'To post an entry you must register. Please use your full name, because this is'  + CRLF +
        'the name that will show up in the user listing.' + CRLF + CRLF +
        'Best regards,' + CRLF +
        'Erik P. Ernst, moderator (ADMIN)' + CRLF + 'Navision Online User Group' + CRLF + 'Email: eernst@bmiusa.com';
  
MAPIMessages.AddressResolveUI(TRUE);
MAPIMessages.ResolveName;
MAPIMessages.Action(3); // Send

The thing is that the you can make the length of the Automation property MAPIMessages.MsgNoteText longer than what Navision supports. Best regards, Erik P. Ernst, webmaster Navision Online User Group

Hi, Navision doesn’t allow you to use more than 250 chars. mail.Body can have more than 250 chars, just as long Navision doesn’t have to do anything with it. So if you say: mail.Body = mail.Body + some text, Navision will say: Hey, mail.Body has more than 250 chars. But, if you say: mail.Body=sometext+some other text + some other text + etc. Navision will not complain. Just make sure you fill mail.Body just once, with as much as text as you like, seperated in blocks with max. 250 chars. You can use an array for this: IF pRecBody.FIND(’-’) THEN REPEAT sometext[i]=pRecbody.Text; i:=i+1; UNTIL pRecBody.NEXT < 1; mail.Body := sometext[1]+sometext[2]+sometext[4] …etc. Anolis Sittard Netherlands

Admin : This works indead but is not dynamic ! I want to pass my body with parameters when the following code is written you get the same error IF pRecBody.FIND(’-’) THEN REPEAT MapiMessages.MsgNoteText := mapiMessages.MsgNoteText + pRecbody.Text ; UNTIL pRecBody.NEXT < 1; Anolis : I also tryed your solution with an array[100] but then you get following error : There is not sufficient available space in the C/AL stack memory … Anyone ?

What kind of system do you use? I mean, how much memory do you have in your sustem? Do you get the same error when you use only 10 elements in the array? Anolis Sittard Netherlands

I’m using a PIII with 512MB internal memory. The server is a compaq raid system PIII with 1GB internal memory I think this must do it ! The arraylen i can use depends on the length of the data i want to mail ! Sometimes 50 elements sometimes 10 Greetings

Make sure the elements of the array are not bigger than 250 chars, and that you declare the array correctly. I just tried about everything, but I was not able to let Navision generate the Error about the C/AL stack. Maybe (I’m not sure at all) it has something to do with the cache settings of your database. My test-database has a cache of 500KB, CommitCach=false. One other possibility: maybe you are running a lot of other applications besides Navision? Anolis Sittard Netherlands

Such errors pop up’s then you using recursive func. Do you use them ? Another reason can be usage of a lot of big local variables, becouse local variables are stored in stack. Or you making a lot of calls to func with big variables. Another programs don’t have any influence to C/AL stack.

Sorry DB but i m not using recursive functions and every var is a global !

quote:


Originally posted by KurtJuvyns: Admin : This works indead but is not dynamic ! I want to pass my body with parameters when the following code is written you get the same error


True, but I would think that most developers here in this forum would know enough to do this i.e. using a comment table in a similar fashion as what you did below.

quote:


Originally posted by KurtJuvyns: IF pRecBody.FIND(’-’) THEN REPEAT MapiMessages.MsgNoteText := mapiMessages.MsgNoteText + pRecbody.Text ; UNTIL pRecBody.NEXT < 1;


Just one question: This didn’t give you any problems? Right? Best regards, Erik P. Ernst, webmaster Navision Online User Group

Admin, Ofcourse i tryed to create it dynamic (with a table and a loop) and no it didn’t work ! K.

I would have believed so, but then again, when I’m think about it, then I understand that it wouldn’t work. So left is basically the ARRAY option mentioned here. I know should work, because I’ve tried serveral times. Unless someone has better ideas. Best regards, Erik P. Ernst, webmaster Navision Online User Group

I think to remember that someone once described the following solution: Write your message into a .TXT file and attach the .TXT-file to the message. Leave (that’s important!) the body-text empty. If both conditions are met: 1) Bodytext is empty and 2) Only attachment is a Text-File then Outlook will insert the Text-File in the body. I never tried that myselfes so don’t blame me if it doesn’t work. Personally I do another approach anyway: i write my Messages via Automation to Winword and then call WinWord to send it as e-mail. (But that’s another story) Marcus Fabian phone: +41 79 4397872 m.fabian@thenet.ch

Your address is automatically inserted by MAPI, the same way as when you select to send an email directly from Navision. Your address is stored in you default MAPI profile. Best regards, Erik P. Ernst, webmaster Navision Online User Group

Moved from “Attain Developer Forum” to “Attain Developer FAQ” forum.