Results 1 to 6 of 6

Thread: Outlook mail msg body-end of line problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497
    I'm using outlook objects, creating a mail message with .CreateItem(olMailItem). I've tried assigning text to a string like this:

    sBody = sBody & sNewString & vbNewLine

    and like this:

    sBody = sBody & sNewString & vbCrLf

    But when I set the .Body property of the mail item =sBody, and .Send the message, the text body is one big string, no end of lines anywhere. ??
    end war
    stop greed

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    Don't have too much time to look into this...
    but if u break it this way... it should work

    .Body = .Body & " The string u want: " & vbNewLine
    .Body = .Body & " Please remember to !" & vbNewLine

    or if u insist not to do it like that...
    I don't know.. try to turn sBody into a variant..

    May be that will make a difference

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497

    Thanks, and I found my problem

    I was writing the body to a text file then reading it. I think the vbNewLine char was lost in the translation. Thanks for your reply.
    end war
    stop greed

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ..Curious

    Interesting...

    How did u solve it?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497

    solution..

    I was writing to a text file:

    Print #iFile, sMessageLine & vbNewLine

    Then I was reading from the text file and concatenating a string:

    Line Input #1, sMessageLine
    sBody = sBody & sMessageLine

    Then:

    .Body = sBody

    I moved the concat of vbNewLine from the Print # statement to the sBody = statment. Don't know alot about text files, maybe it couldn't be stored/retrieved properly.

    Thanks for asking!
    end war
    stop greed

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'it can be done from a file like this.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    
        Dim objOutlook As New Outlook.Application
        Dim objOutlookMsg As Outlook.MailItem
        
        ' Create new message
        Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    
    'file format is this  just 3 lines for testing.
            'my old line
            'my new line
            'my ending line
      
    'open the file and read it
        Dim mystring As String, myNewString As String
        
        Open "c:\my documents\myfile.txt" For Input As #1
           Do Until EOF(1)
             Line Input #1, mystring
             myNewString = myNewString & vbCrLf & mystring
           Loop
             Close #1
          
        With objOutlookMsg
        .To = "[email protected]"
        .Subject = "Just A Dummy Old Test..."
        .Body = myNewString
        .Importance = olImportanceHigh
        .Send
        End With
     
        Set objOutlookMsg = Nothing
        
        ' Close Outlook instance: Important!
        Set objOutlook = Nothing
     End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width