mibuso.com

Microsoft Business Solutions online community
It is currently Sat May 25, 2013 8:33 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: oSendMail Object
PostPosted: Sat Mar 19, 2005 1:20 am 
Offline

Joined: Wed Oct 08, 2003 7:22 pm
Posts: 109
Location: San Jose, California
Country: United States (us)
I am modifying the Mail Codeunit to include a standard message when the interaction log is run. I am trying to format the Body of the email to be in HTML, but am having little success.

I checked the object browser for the standard outlook mailitem, as I believe the 'NS Outlook Synchronization Handler'.OSendMail is just a wrapper for that object. It appears that the BodyFormat property accepts 2 for HTML format, however I am not getting it in HTML. Here is a sample of what I am doing. Any ideas?



OSendMail."To" := ToName;
OSendMail.CC := CCName;
OSendMail.Subject := Subject;

Body:= 'This is a test of the <B>emergency</B> <U>broadcast</U> system...';


IF ISCLEAR(BSTRConverterBody) THEN
CREATE(BSTRConverterBody);

IF Body <> '' THEN BEGIN
BSTRConverterBody.ResetBSTR;
BSTRConverterBody.AppendNextStringPortion(Body);
END;
OSendMail.Body := BSTRConverterBody;
OSendMail.BodyFormat(2);

IF ISCLEAR(BSTRConverterAttachFileName) THEN
CREATE(BSTRConverterAttachFileName);

IF AttachFileName <> '' THEN BEGIN
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName);
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
END;

OSendMail.OpenDialog := OpenDialog;

MailSent := OSendMail.Send;
ErrorNo := OSendMail.ErrorStatus;
OApplication.Logoff;

_________________
[url]www.Oztera.com[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 3:26 pm 
Offline

Joined: Wed Sep 15, 2004 3:39 pm
Posts: 26
Location: Faroe Islands
Is it possible that you're not getting any HTML-formatting due to the fact that your body-code are without the HTML-tags (<html> </html>)?

Another reason could be the Outlook-client setup: What type of mail format are the outlook-client using (Tools -> Mail-format)?


Top
 Profile  
 
 Post subject: Tried it...
PostPosted: Tue Mar 22, 2005 6:21 pm 
Offline

Joined: Wed Oct 08, 2003 7:22 pm
Posts: 109
Location: San Jose, California
Country: United States (us)
I also tried multiple values for the format property...

Nada...

_________________
[url]www.Oztera.com[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 9:21 am 
Offline

Joined: Wed Jun 11, 2003 3:34 pm
Posts: 50
Location: Kiev, Ukraine
Country: Ukraine (ua)
Hi,

It is true - OutlookSyncHandler wraps Body Property of the MailItem. The BodyFormat property specifies the message format only and does not allow the use of HTML tags.

MailItem has a property called HTMLBody to enable using HTML, but OutlookSyncHandler currently does not wrap it.

_________________
Best regards,
Dmitry


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 5:55 pm 
Offline

Joined: Wed Oct 08, 2003 7:22 pm
Posts: 109
Location: San Jose, California
Country: United States (us)
MS said they didn't expose that property in the wrapper. Did you find a way around that? I know I could use the Native Outlook object, but I beleive I would loose the interaction log entry functionality...i.e. linking the email in the record, etc. I also thought maybye after the item was created using the Navision object, I could somehow find and intercept it using the Outlook objects.


Mike

_________________
[url]www.Oztera.com[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 9:08 am 
Offline

Joined: Wed Jun 11, 2003 3:34 pm
Posts: 50
Location: Kiev, Ukraine
Country: Ukraine (ua)
Quote:
but I beleive I would loose the interaction log entry functionality...i.e. linking the email in the record...


If you are talking about E-Mail logging functionality that loggs outgoing e-mails as Interaction Log Entries, then you don't have to worry. When you send an e-mail (no matter how) you should have a rule in Outlook which places this e-mail into your Queue folder, then Navision checks this folder (interval and other settings are defined in the Relationship Management Setup) and retrieves this mail. After that Navision tries to find out if an interaction has been already logged for it using the LoggedAsInternalInteraction procedure in COD5064 and if it finds this ILE - it links the e-mail in outlook with this ILE.

So you can make your own code that sends e-mails using Outlook Object Model. Just remember that OSendMail supresses Outlook Security Messages while sending e-mails (those where you have to confirm that another application is sending the e-mail on your behalf). When programming against OOM you cant avoid them and it can be very annoing...

And I also dont think that you can intersept OSendMail - the Save method for it is not exposed either, no Save - no EntryID, no object to intersept...

_________________
Best regards,
Dmitry


Top
 Profile E-mail  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 12:55 am 
Offline

Joined: Tue Sep 27, 2005 12:06 am
Posts: 2
Location: Tucson, AZ
I may have the solution, depending on what you are trying to do.

I was able to send an E-Mail Signature generated by Navision to Outlook formatted as HTML.

If you are using Navision 3.7, I recommend you update your E-Mail code to match Navision 4.0 as much as possible.

I use Navision 3.7 on Windows XP and Outlook 2003.

To update the 3.7 code to match 4.0 code:

I updated my E-Mail code to act like Navision 4.0 because 4.0 uses the OLHandler.dll which eliminates the Outlook Security Popups we got when we sent mails through Navision, when Outlook tried to pop up a scheduled task, and when Navision tried to log E-Mails.

I registered the OLHandler.dll that 4.0 uses.

I upgraded the "Mail" codeunit to match the 4.0 Mail codeunit with all the same code and same variables.

I exported all the codeunits, reports, forms, and tables I could export as text files and searched through them to find any "Unknown Automation" objects. Where those objects called for Outlook, I assigned them the Automation object created by registering the OLHandler.dll. The automatian object name is called 'NS Outlook Synchronization Handler'.

(We still get the Outlook security pop-up when we first assign the Outlook folders on the Salesperson Card form that Navision will use to synchronize with, but that is only done once; and, we still get the pop ups when we use Interaction Templates that use MS Word to merge with Outlook. That doesn't happen very often, since only our advanced users utilize those Interaction Templates anyway. Otherwise, our Outlook Integration is free or warning pop ups).

To format the mail to HTML:

I modified the NewMessage function in the Mail codeunit by adding the "OSendMail.BodyFormat(2);" command line to tell the MailHandler to use HTML format.

I created a chrLineBreak variable of data type "Char."

I assigned this variable the value of 13 and when I used the AddBodyLine to write it to Outlook, I formatted the chrLineBreak variable to a string:

AddBodyLine(FORMAT(chrLineBreak));

Doing all the above. I had a Navision runnig 3.7 without Outlook security popups, using line breaks, and formatting in HTML.

Below is an example of the Outlook Signature coming out in HTML format:

---------------------------------------------------
IF ISCLEAR(OApplication) THEN
CREATE(OApplication);

IF (NOT OApplication.Logon(TRUE,'','',FALSE,FALSE)) THEN BEGIN
OApplication.Logoff;
EXIT
END;

IF ISCLEAR(OSendMail) THEN
CREATE(OSendMail);

ErrorNo := 0;

OSendMail."To" := ToName;
OSendMail.CC := CCName;
OSendMail.Subject := Subject;


IF ISCLEAR(BSTRConverterBody) THEN
CREATE(BSTRConverterBody);

chrLineBreak := 13; // Assign char(13) value to char variable

recCompanyInformation.RESET(); // "Company Information" Table
recCompanyInformation.INIT();
IF recCompanyInformation.FIND('-') THEN
BEGIN
txtCompanyName := recCompanyInformation."Name 2";
txtHomePage := recCompanyInformation."Home Page";
END;

recSalesperson.RESET(); // "Saleperson/Purchaser" Table
recSalesperson.INIT();
recSalesperson.SETRANGE("Navision User ID",USERID);
IF recSalesperson.FIND('-') THEN
BEGIN
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson.Name);
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson."Job Title");
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(txtCompanyName);
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson."Phone No.");
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson.FaxNo);
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(txtHomePage);
END;

IF Body <> '' THEN BEGIN
BSTRConverterBody.ResetBSTR;
BSTRConverterBody.AppendNextStringPortion(Body);
END;

OSendMail.Body := BSTRConverterBody;
OSendMail.BodyFormat(2);

IF ISCLEAR(BSTRConverterAttachFileName) THEN
CREATE(BSTRConverterAttachFileName);

IF AttachFileName <> '' THEN BEGIN
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName);
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
END;

OSendMail.OpenDialog := OpenDialog;

MailSent := OSendMail.Send;
ErrorNo := OSendMail.ErrorStatus;
OApplication.Logoff;
--------------------------------------------

I hope this helps.

_________________
Best Regards,

relliot


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 2:05 pm 
Offline

Joined: Tue Jul 26, 2005 9:28 am
Posts: 234
Location: Sweden
Country: Sweden (se)
relliot wrote:
I may have the solution, depending on what you are trying to do.

I was able to send an E-Mail Signature generated by Navision to Outlook formatted as HTML.

If you are using Navision 3.7, I recommend you update your E-Mail code to match Navision 4.0 as much as possible.

I use Navision 3.7 on Windows XP and Outlook 2003.

To update the 3.7 code to match 4.0 code:

I updated my E-Mail code to act like Navision 4.0 because 4.0 uses the OLHandler.dll which eliminates the Outlook Security Popups we got when we sent mails through Navision, when Outlook tried to pop up a scheduled task, and when Navision tried to log E-Mails.

I registered the OLHandler.dll that 4.0 uses.

I upgraded the "Mail" codeunit to match the 4.0 Mail codeunit with all the same code and same variables.

I exported all the codeunits, reports, forms, and tables I could export as text files and searched through them to find any "Unknown Automation" objects. Where those objects called for Outlook, I assigned them the Automation object created by registering the OLHandler.dll. The automatian object name is called 'NS Outlook Synchronization Handler'.

(We still get the Outlook security pop-up when we first assign the Outlook folders on the Salesperson Card form that Navision will use to synchronize with, but that is only done once; and, we still get the pop ups when we use Interaction Templates that use MS Word to merge with Outlook. That doesn't happen very often, since only our advanced users utilize those Interaction Templates anyway. Otherwise, our Outlook Integration is free or warning pop ups).

To format the mail to HTML:

I modified the NewMessage function in the Mail codeunit by adding the "OSendMail.BodyFormat(2);" command line to tell the MailHandler to use HTML format.

I created a chrLineBreak variable of data type "Char."

I assigned this variable the value of 13 and when I used the AddBodyLine to write it to Outlook, I formatted the chrLineBreak variable to a string:

AddBodyLine(FORMAT(chrLineBreak));

Doing all the above. I had a Navision runnig 3.7 without Outlook security popups, using line breaks, and formatting in HTML.

Below is an example of the Outlook Signature coming out in HTML format:

---------------------------------------------------
IF ISCLEAR(OApplication) THEN
CREATE(OApplication);

IF (NOT OApplication.Logon(TRUE,'','',FALSE,FALSE)) THEN BEGIN
OApplication.Logoff;
EXIT
END;

IF ISCLEAR(OSendMail) THEN
CREATE(OSendMail);

ErrorNo := 0;

OSendMail."To" := ToName;
OSendMail.CC := CCName;
OSendMail.Subject := Subject;


IF ISCLEAR(BSTRConverterBody) THEN
CREATE(BSTRConverterBody);

chrLineBreak := 13; // Assign char(13) value to char variable

recCompanyInformation.RESET(); // "Company Information" Table
recCompanyInformation.INIT();
IF recCompanyInformation.FIND('-') THEN
BEGIN
txtCompanyName := recCompanyInformation."Name 2";
txtHomePage := recCompanyInformation."Home Page";
END;

recSalesperson.RESET(); // "Saleperson/Purchaser" Table
recSalesperson.INIT();
recSalesperson.SETRANGE("Navision User ID",USERID);
IF recSalesperson.FIND('-') THEN
BEGIN
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson.Name);
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson."Job Title");
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(txtCompanyName);
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson."Phone No.");
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(recSalesperson.FaxNo);
AddBodyline(FORMAT(chrLineBreak)); // put in line break
AddBodyline(txtHomePage);
END;

IF Body <> '' THEN BEGIN
BSTRConverterBody.ResetBSTR;
BSTRConverterBody.AppendNextStringPortion(Body);
END;

OSendMail.Body := BSTRConverterBody;
OSendMail.BodyFormat(2);

IF ISCLEAR(BSTRConverterAttachFileName) THEN
CREATE(BSTRConverterAttachFileName);

IF AttachFileName <> '' THEN BEGIN
BSTRConverterAttachFileName.ResetBSTR;
BSTRConverterAttachFileName.AppendNextStringPortion(AttachFileName);
OAttachments := OSendMail.Attachments;
OAttachment := OAttachments.Add(BSTRConverterAttachFileName);
END;

OSendMail.OpenDialog := OpenDialog;

MailSent := OSendMail.Send;
ErrorNo := OSendMail.ErrorStatus;
OApplication.Logoff;
--------------------------------------------

I hope this helps.


Hmm, how does your AddBodyline function look like? I remember having a problem with sending emails > 1024 chars


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 6:21 pm 
Offline

Joined: Tue Sep 27, 2005 12:06 am
Posts: 2
Location: Tucson, AZ
Since the AddBodyLine() function only inserts text within the parentheses and does not put in any line breaks, you could insert two or more strings of 1024 characters back to back and they would look like one. For instance, if you wrote:

AddBodyLine('First part of broken str');
AddBodyLine('ing and middle part of broken str');
AddBodyLine('ing and last part of brokent string.');

When it's sent to Outlook, it would look like "First part of broken string and middle part of broken string and last part of broken string."

If you needed to, I guess you could create entire paragraphs that way, and I would use this to send autogenerated E-Mails.

However, for regular E-Mails sent to customers and so forth, we have the CRM module for Navision and it's integrated with Outlook. Se we just use Navision to Open Outlook and add the E-Mail Signature to the body and initialize the HTML format. Then the rest is done within Outlook itself.

I have worked with the SMTP ocx that you can download also from mibuso.com to send auto generated E-Mails, and after looking at the new Outlook Automation object that is created by the OLHandler.dll, I beleive the OLHandler.dll has the same functionality (once you update your 3.7 code to match 4.0 to eliminate outlook warning pop ups). Both can add lines up to 1024 characters, and it looks like both support Bcc addresses. (That is, I see that the Bcc is available in the OLHandler.dll, but I haven't tried it yet.)

But in my experience with the SMTP ocx, it does not put a copy of the E-Mail in a user's sent items, and when you add a line, it adds a line, and when you add another line, it creates a brand new line and doesn't let you insert them back to back so if you typed:

ocxSMTP.AddLine('First part of broken str');
ocxSMTP.AddLine('ing and middle part of broken str');
ocxSMTPAddLine('ing and last part of brokent string.');

It would look like:

First part of broken str
ing and middle part of broken str
ing and last part of broken str

Personally, I like the new OLHandler.dll.

I hope that this is helpful, and I hope that it is not too much writing for a simple answer.

_________________
Best Regards,

relliot


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 3:48 pm 
Offline

Joined: Wed Jun 04, 2003 2:28 pm
Posts: 276
Location: Antwerpen
Country: Belgium (be)
i've tried the bodyformat thingy.

It did change the body type to HTML

but all my begin and end tag are converted to &gt; and &lt; notation.

so ....

it didn't work.

Does anybody have an idea how i can skip the text buffer sh$t from navision?

Regards,

_________________
Now, let's see what we can see.
...
Everybody on-line.
...
Looking good!


Top
 Profile  
 
 Post subject: eMail body HTML
PostPosted: Tue Oct 24, 2006 5:02 pm 
Offline

Joined: Thu Aug 10, 2006 3:28 pm
Posts: 2
Location: Paris
Country: France (fr)
The Value of the property for the body of an eMail is:

olFormatUnspecified 0 Format non spécifié. texte brut.
olFormatPlain 1 Le texte de Body est en texte brut.
olFormatHTML 2 Le texte de Body est en HTML.
olFormatRichText 3 le texte de Body est en RTF.

lui préférer le HTML pour des raisons de compatibilité de lecteurs de messagerie.

You have to put it in the Codeunit 397 'Mail', like:

NewMessage(ToName : Text[80];CCName : Text[80];Subject : Text[260];Body : Text[260];AttachFileName : Text[260];OpenDialog : Boolean) Ma
IF ISCLEAR(OApplication) THEN
CREATE(OApplication);

IF (NOT OApplication.Logon(TRUE,'','',FALSE,FALSE)) THEN BEGIN
OApplication.Logoff;
EXIT
END;

IF ISCLEAR(OSendMail) THEN
CREATE(OSendMail);

ErrorNo := 0;

OSendMail."To" := ToName;
OSendMail.CC := CCName;
OSendMail.Subject := Subject;
//>>CHRE
OSendMail.BodyFormat := 2;
//<<CHRE

IF ISCLEAR(BSTRConverterBody) THEN
CREATE(BSTRConverterBody);
...


Top
 Profile E-mail  
 
 Post subject: Re: oSendMail Object
PostPosted: Mon Apr 12, 2010 11:05 pm 
Offline

Joined: Mon Apr 12, 2010 10:51 pm
Posts: 1
Country: Germany (de)
Hi there,
I work with Codeunit 397 (NAV 2009 SP1). In Function NewMessage the format is set zu html: OSendMail.BodyFormat(2);
Lines are set with AddBodyline. If in the lines there are html-tags they are not interpreted. E.g. <b> is in the mail instead of a bold text.
What could I do to change this?
My second trial is to work directly with the outlook library. The mailitem.htmlbody is limited to 1024 - my mailtexts are longer than this so I'm as far as before. Is there a way to add more text than 1024 signs via outlook-automations?
Does anybody know a solution for one of the problems?
Greetings,
Sandra


Top
 Profile E-mail  
 
 Post subject: Re: oSendMail Object
PostPosted: Mon May 17, 2010 2:17 am 
Offline

Joined: Wed Dec 09, 2009 9:59 pm
Posts: 1
Country: Australia (au)
Has anyone got a workable solution to this problem? I have the same issues as skaufmann.

We can send SMTP emails with HTML formatting but we would like to be able send HTML emails via Outlook so that it shows up in a users Sent Items folder.

Is there anyway to add an HTML document as the body of an Outlook email?


Top
 Profile E-mail  
 
 Post subject: Re: oSendMail Object
PostPosted: Tue Nov 29, 2011 8:59 pm 
Offline

Joined: Wed Oct 08, 2003 7:22 pm
Posts: 109
Location: San Jose, California
Country: United States (us)
I am wondering if anyone has found an issue to this problem. We can send html emails using SMTP, but not with Outlook object. Would like to use the wrapped object for future upgrades as well as the security message. If you have a direct method that takes these issues into account, I would be very interested as well.

Thanks in advance...

_________________
[url]www.Oztera.com[/url]


Top
 Profile  
 
 Post subject: Re: oSendMail Object
PostPosted: Wed Nov 30, 2011 10:52 am 
Offline
NAV TechDays 2013 attendee

Joined: Mon May 07, 2007 11:47 am
Posts: 96
Location: At Work
Country: Netherlands (nl)
Have a look at this: http://www.mibuso.com/dlinfo.asp?FileID=1412
It should be possible with Word2010 automation controls as well. Create a word doc and send it through Word.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: