can not create multi line email body

darshanm
Member Posts: 280
Hi,
I am generating email from Navision code unit MAIL.
I am facing problem while creating email body.
I am using newmessage() function to send the mail, But
I can not format the body of the email.
Please let me know how to use Mail.AddBodyLine()
function.
I am generating email from Navision code unit MAIL.
I am facing problem while creating email body.
I am using newmessage() function to send the mail, But
I can not format the body of the email.
Please let me know how to use Mail.AddBodyLine()
function.
Darshan Mungekar
Senior Consultan
Senior Consultan
0
Comments
-
You can generate your new lines as follows, where CR is a Char type variable.
CR := 13; .. .. Mail.AddBodyline('body line 1' + FORMAT(CR)) ; Mail.AddBodyline('body line 2'); .. ..
0 -
Hi,
I am writing below code in one of the report, which directly
sends an email to user. please tell me where to put code for
Mail.AddBodyline('body line 2');
Body := Item.Description + FORMAT(ValueEntryBuffer."Invoiced Quantity");
.....
......
Mail.NewMessage(SalesReceivablesSetup."Item Notify To",'','Item Sales Qty',Body,'',FALSE);Darshan Mungekar
Senior Consultan0 -
Any help on this....Darshan Mungekar
Senior Consultan0 -
Try with AddBodyline(TextLine : Text[260]). But you are limited to 260 chars for mail body.
You will have to split code in NewMessage where body is appended.IF ISCLEAR(BSTRConverterBody) THEN CREATE(BSTRConverterBody); IF Body <> '' THEN BEGIN BSTRConverterBody.ResetBSTR; BSTRConverterBody.AppendNextStringPortion(Body); END; OSendMail.Body := BSTRConverterBody;
I.e. for only one new-line:IF Body <> '' THEN BEGIN BSTRConverterBody.ResetBSTR; if strpos(body,'\') <> 0 then begin appendnextstringportion(copystr(body,1,strpos(body,'\')); appendnextstringportion(copystr(body,strpos(body,'\')+1,260); end else BSTRConverterBody.AppendNextStringPortion(Body); end ;
0 -
hi,
i m also facing the same problem.
i hv put folloeing code in function NewMessage in codeunit mail:
I.e. for only one new-line:
Code:
IF Body <> '' THEN BEGIN
BSTRConverterBody.ResetBSTR;
if strpos(body,'\') <> 0 then
begin
appendnextstringportion(copystr(body,1,strpos(body,'\'));
appendnextstringportion(copystr(body,strpos(body,'\')+1,260);
end
else BSTRConverterBody.AppendNextStringPortion(Body);
end ;
but in this fuction above of this code there are couple of lines:
IF (NOT OApplication.Logon(TRUE,'','',FALSE,FALSE)) THEN BEGIN
OApplication.Logoff;
EXIT
END;
this is the fourth line in this function. From here Exit function is working and my remaining function is not executing.
plz suggest something.Bakshi Bilochi0 -
any more inputs on this problem???Darshan Mungekar
Senior Consultan0 -
darshanm wrote:any more inputs on this problem???
You can try changing the code to look like this:
Old:IF (NOT OApplication.Logon(TRUE,'','',FALSE,FALSE)) THEN BEGIN
New:IF (NOT OApplication.Logon(FALSE,Profilename,MailPW,FALSE,FALSE)) THEN BEGIN
orIF (NOT OApplication.Logon(FALSE,Profilename,MailPW,FALSE,TRUE)) THEN BEGIN
where profilename is the name of the outlook profile and MailPW the appropriate password. But beware of the security issue when setting a hardcoded plaintext password!Torsten
MCP+I, MCSE NT, Navision MCT (2004,2005)0 -
my Outlook is running and navision sends email to the user perfectly.
But i want to create a email body with multi line, which i am not
able to do...Darshan Mungekar
Senior Consultan0 -
Hi
Have you tried it like thisBody := Item.Description + FORMAT(ValueEntryBuffer."Invoiced Quantity"); Mail.AddBodyLine(Body); Mail.AddBodyLine('Regards,'); Mail.NewMessage(SalesReceivablesSetup."Item Notify To",'','Item Sales Qty','','',FALSE);
Albert0 -
hi,
i hv used this code also but still all the data is going in single line in body.
plz suggest something else.Bakshi Bilochi0 -
Have you tried inserting the Cariage Return & Line Feed characters manually?
I had to do some testing for a project with sending emails, but that piece was scrapped. So I had the same problem and I never got around to trying it by passing through those characters manually. It may be worth a try.0 -
bakshi wrote:hi,
i hv used this code also but still all the data is going in single line in body.
plz suggest something else.
For the linefeed, simply add the CRLF like this:IF Body <> '' THEN BEGIN CR := 13; LF := 10; BSTRConverterBody.ResetBSTR; IF STRPOS(Body,'\') <> 0 THEN BEGIN BSTRConverterBody.AppendNextStringPortion(COPYSTR(Body,1,STRPOS(Body,'\')-1) + FORMAT(CR) + FORMAT(LF)); BSTRConverterBody.AppendNextStringPortion(COPYSTR(Body,STRPOS(Body,'\')+1,260)); END ELSE BSTRConverterBody.AppendNextStringPortion(Body); END ;
Torsten
MCP+I, MCSE NT, Navision MCT (2004,2005)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