Results 1 to 11 of 11
  1. #1
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936

    Line feed for use in MS Outlook email


    I open a new message in MS Outlook using "Application.FollowHyperlink". In the body of the message is a list of orders from a query and I would like each order number to be on a new line. I have tried vbCrLf, Chr(10/13), <br> - nothing seems to be working. The string variable looks right in the immediate window but when the message opens they are all on one line.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Can you show readers some sample data?
    Or the file ( or ports of it) and your code/

  3. #3
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Code:
    Public Function aaa()
        
        Dim strWrk As String, x As Integer, y As String
        y = "1234"
        For x = 1 To 4
            strWrk = strWrk & y & x & vbCrLf
        Next
        Debug.Print strWrk
        aaa = strWrk
        
    End Function
    Result in message body:
    12341123421234312344
    Attached Thumbnails Attached Thumbnails Code.jpg  

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Sorry:
    Code:
    Private Sub Cmd_Task1_Email_Click()
    
        Dim sWebPath As String, sFullLinkPath As String, T1Body As String
    
        T1Body = aaa()
        sWebPath = "mailto:xxx@yyy" & "?subject=BPO Orders with No Agent&body=" & T1Body
        sFullLinkPath = sWebPath
        Application.FollowHyperlink sFullLinkPath
    End Sub

  5. #5
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    ???Nothing jumps out to explain your findings.

    Here is a sample from blueclaw that uses vbCrLf


    Update: Sent after your first post; didn't see post #4

    You may want to adjust you function as below and try it. (just a guess)

    Code:
    Public Function aaa()   As String
        
        Dim strWrk As String, x As Integer, y As String
        y = "1234"
        For x = 1 To 4
            strWrk = strWrk & y & x & vbCrLf
        Next
        Debug.Print strWrk
        aaa = strWrk
        
    End Function

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Thanks, Orange, sadly no change.

  7. #7
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    AFAIK, you cannot pass carriage returns or line feeds to an email this way. Outlook (and probably most email programs) don't recognize these vba values since the email is HTML. Not sure what the implication is if the email is plain text other than to say they still will not be recognized.

    You have to use automation and construct the .Body, concatenating the html <B> or <P> characters where needed.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Can you be provide details on what you mean?

  9. #9
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    The link Orange provided uses Automation in this section Select Case Me.Email_Output_Option, but my recollection is that vbCrlf doesn't get recognized. That and the fact that I've tried before made me answer that way, especially for the FollowHyperlink method you are trying to use. So I'm guilty of not checking the link provided, where I see they claim it works when using Automation. Your reply that it doesn't without providing your attempted code may have caused me to post information that is not correct. If so, my fault, not yours.

    So you can re-read the link or Google 'ms access vba send email' or something like that. Anything you find that contains a line like
    Set oLook = CreateObject("Outlook.Application") is an example that uses Automation.

    I do believe there is another way, and that is to use the SendObject method of the DoCmd object. Your code should work if you use something like
    DoCmd.SendObject acSendNoObject, , , "xxx@yyy", , , "BP ORDERS", T1Body
    instead of FollowHyperlink. As written, the email will be opened for edit, so you should trap for it being closed instead of sent otherwise you'll get an error message about the action being cancelled. The method parameters are like so:
    DoCmd.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)

  10. #10
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Brilliant, thanks, I will play around with these and see what happens.

  11. #11
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    WORKED! I didn't even bother to try the CreateObject as SendObject worked.

    Setting up the string:
    Code:
    BodyStr = BodyStr & Trim(rst!Valuation) & vbCrLf
    Creating the editable email message:
    Code:
        DoCmd.SendObject acSendNoObject, , , "xxx@yyy", , , "BPO Orders with No Agent", T1Body

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-14-2015, 07:24 AM
  2. New line in html email form field
    By srk999 in forum Forms
    Replies: 3
    Last Post: 02-18-2014, 06:34 PM
  3. Replies: 7
    Last Post: 11-19-2013, 01:58 PM
  4. Importing data with line feed
    By wlcummings in forum Import/Export Data
    Replies: 10
    Last Post: 05-18-2011, 12:52 PM
  5. VBA check for email subject line
    By problem_addic in forum Access
    Replies: 4
    Last Post: 03-12-2010, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums