I'm working with IP2010 (rich client) and I have a need to open Outlook prior to sending an email. I have a view that mimics a new email message like in Outlook and it has fields for To, CC, Subject and Body. My Body field is a rich text box that I'm populating based on an XML file (I have email templates that set what shows up in the body of the email message).
I have the XML data connection populating correctly and I've written the code to open Outlook successfully and I can pass in the information from my view into the mail message. However, I cannot get the Body field to set correctly. My body field in the view contains multiple paragraphs, but when I send it to Outlook, it's removing the paragraph breaks so I'm left with one long paragraph. I've tried setting the field with the InnerXML and OuterXML and even Value. I've tried setting the Body in the email message as HTML and Rich Text, but neither are working.
Here is my code that I'm working with:
Dim myNamespace As String = NamespaceManager.LookupNamespace("my")
Dim nav1 As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:LeaseFlow/my:EmailBody", NamespaceManager)
Dim nav2 As XPathNavigator = MainDataSource.CreateNavigator().SelectSingleNode("/my:LeaseFlow/my:EmailHeader", NamespaceManager)
Dim emailmessage As String
Dim taskname As String, SentTo As String, Subject As String, CC As String, BCC As String
emailmessage = nav1.SelectSingleNode("my:emailbodyMessage", NamespaceManager).InnerXML
SentTo = nav2.SelectSingleNode("my:emailheaderTo", NamespaceManager).Value
Subject = nav2.SelectSingleNode("my:emailheaderSubject", NamespaceManager).Value
CC = nav2.SelectSingleNode("my:emailtoCC", NamespaceManager).Value
BCC = nav2.SelectSingleNode("my:emailtoBCC", NamespaceManager).Value
Dim oApplication As Microsoft.Office.Interop.Outlook._Application = New Microsoft.Office.Interop.Outlook.Application
Dim newMail As Microsoft.Office.Interop.Outlook.MailItem = oApplication.CreateItem(OlItemType.olMailItem)
newMail.BodyFormat = OlBodyFormat.olFormatHTML
newMail.To = SentTo
newMail.Subject = Subject
newMail.Body = emailmessage
newMail.CC = CC
newMail.BCC = BCC
newMail.Display(False)
--------------------------------------------------------------------
Can anyone help me out please? I'm seriously stuck.
Thank you in advance!
Chris