Embedded vbLF in message body is converted to vbCRLf 
Author Message
 Embedded vbLF in message body is converted to vbCRLf

I'm working on a application where messages are constructed automatically
and sent to another application. The other application expects records to be
of fixed length and terminated with a line feed character. Outlook appears
to be converting the line feed to a CR-LF pair.

The application is written in VB6, using Outlook 2000 object library.

My question is, how do I write a byte stream to the message body and not
have it converted by Outlook?

Thanks for any advice.



Fri, 05 Jul 2002 03:00:00 GMT  
 Embedded vbLF in message body is converted to vbCRLf
You can't, as far as I know. Outlook will not only format the text
that is pasted into the Body with carriage returns based on the line
length, but will convert your message into RTF if you touch the Body
property.

Can you paste the text stream into a file and then attach the file to
your message for the other app to use?

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:
> I'm working on a application where messages are constructed
automatically
> and sent to another application. The other application expects
records to be
> of fixed length and terminated with a line feed character. Outlook
appears
> to be converting the line feed to a CR-LF pair.

> The application is written in VB6, using Outlook 2000 object
library.

> My question is, how do I write a byte stream to the message body and
not
> have it converted by Outlook?

> Thanks for any advice.



Sat, 06 Jul 2002 03:00:00 GMT  
 Embedded vbLF in message body is converted to vbCRLf
What about using CDO? Have you checked whether it also munges the text?
(I'll put it on my list of things to try.)



Quote:
> You can't, as far as I know. Outlook will not only format the text
> that is pasted into the Body with carriage returns based on the line
> length, but will convert your message into RTF if you touch the Body
> property.

> Can you paste the text stream into a file and then attach the file to
> your message for the other app to use?

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



> > I'm working on a application where messages are constructed
> automatically
> > and sent to another application. The other application expects
> records to be
> > of fixed length and terminated with a line feed character. Outlook
> appears
> > to be converting the line feed to a CR-LF pair.

> > The application is written in VB6, using Outlook 2000 object
> library.

> > My question is, how do I write a byte stream to the message body and
> not
> > have it converted by Outlook?

> > Thanks for any advice.



Tue, 09 Jul 2002 03:00:00 GMT  
 Embedded vbLF in message body is converted to vbCRLf
Good idea.

If the message isn't being received in Outlook then it seems to work.
CDO handles it properly, but if the message is received in Outlook it
is munged all over again. The following 2 Subs show that:

Sub TestCDOString()
  Dim oSession As MAPI.session
  Dim oFolder As MAPI.Folder
  Dim oMessage As MAPI.Message
  Dim sTest As String

  sTest = "12345678" & Chr$(10) & "12345678" & Chr$(10) & _
        "12345678" & Chr$(10)
  Set oSession = CreateObject("MAPI.Session")
  oSession.Logon "", "", False, False
  Set oFolder = oSession.Inbox
  Set oMessage = oFolder.Messages.Add
  oMessage.Subject = "Test String"
  oMessage.Text = sTest

  oMessage.Update
  sTest = oMessage.Text
  Debug.Print InStr(1, sTest, Chr$(10))
  Debug.Print InStr(1, sTest, Chr$(13))
  oMessage.Send

  oSession.Logoff
  Set oSession = Nothing
  Set oFolder = Nothing
  Set oMessage = Nothing
End Sub

Sub TestLineFeeds()
  Dim oInspector As Outlook.Inspector
  Dim oOL As Outlook.Application
  Dim sTest As String

  Set oOL = CreateObject("Outlook.Application")
  Set oInspector = Application.ActiveInspector
  sTest = oInspector.CurrentItem.Body
  Debug.Print InStr(1, sTest, Chr$(10))
  Debug.Print InStr(1, sTest, Chr$(13))
End Sub

The output from the first one is 9,0. So the first line feed is in the
correct place and there is no carriage return. The second one, with
the received message opened in Outlook has output of 10,9. So a
carriage return is being inserted into the text stream at the position
just before the first line feed.

What I didn't test was receiving the message into another application
to check if the message is munged after it is sent.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams



Quote:
> What about using CDO? Have you checked whether it also munges the
text?
> (I'll put it on my list of things to try.)



Tue, 09 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. vbscript on devstudio - vbCrLf to vbLf

2. vbCrLf after attachment - (not '.Body')

3. Retrieving message body text of currently selected message

4. vbcrlf or vbCrLf

5. Pasting Excel range as embedded object in outlooks body

6. How can I embed object an office document into Mailitem Body

7. embedding images into the body

8. How to convert the body text of an e-mail to HTML format

9. Send a hyperlink as part of the message body

10. eMail SQL results in message body

11. (*.RTF) as message body to Outlook, Possible???

12. Replacing message body text in Outlook 2000 7 XP

 

 
Powered by phpBB® Forum Software