1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel Cell Email update

Discussion in 'Business Applications' started by rafterman79, Oct 2, 2008.

Thread Status:
Not open for further replies.
Advertisement
  1. rafterman79

    rafterman79 Thread Starter

    Joined:
    Sep 24, 2008
    Messages:
    12
    Hi guys,

    Thanks for sorting me out last time, however I have another query:

    I am using this VB script to email values in cells, the problem is when people have autosignatures with no carriage returns the data in excel is put on the same line as the auto sig, is there a way I can get a carriage return after the data output? I have tried adding Chr(13) (in bold below) but this didnt work.

    Any ideas?

    Thanks,

    Sean

    Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long
    Sub SendEMail()
    Dim Email As String, Subj As String
    Dim Msg As String, URL As String

    Email = " & "," &

    ' Message subject
    Subj = ""
    ' Compose the message
    thisrow = ActiveCell.Row
    Msg = ""
    Msg = Msg & Cells(thisrow, 3) & Chr(44) & Space(1) & Cells(thisrow, 4) & Chr(44) & Space(1) & Cells(thisrow, 5) & Chr(44) & Space(1) & Cells(thisrow, 6) & Chr(44) & Space(2) & Cells(thisrow, 7) & Chr(44) & Space(1) & Cells(thisrow, 8) & Chr(44) & Space(1) & Cells(thisrow, 9) & Chr(44) & Space(1) & Cells(thisrow, 10) & Chr(44) & Space(1) & Chr(13)

    ' Replace spaces with %20 (hex)
    Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
    Msg = Application.WorksheetFunction.Substitute(Msg & Chr(13), " ", "%20")

    ' Replace carriage returns with %0D%0A (hex)
    Msg = Application.WorksheetFunction.Substitute(Msg, Space(1), "%0D%0A")
    ' Create the URL
    URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg
    ' Execute the URL (start the email client)
    ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus
    End Sub
     
  2. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Try using vbCrLf instead of the Chr(13)

    Regards,
    Rollin
     
  3. rafterman79

    rafterman79 Thread Starter

    Joined:
    Sep 24, 2008
    Messages:
    12
    Tried that but on Lotus Notes it does not work.

    Any other ways of doing it I could try?
     
  4. rafterman79

    rafterman79 Thread Starter

    Joined:
    Sep 24, 2008
    Messages:
    12
    I have noticed that the cursor is at the start of the output on the email.

    Dont know if this makes any difference but it might.
     
  5. rafterman79

    rafterman79 Thread Starter

    Joined:
    Sep 24, 2008
    Messages:
    12
    Msg = Application.WorksheetFunction.Substitute(Msg & Chr(13), " ", "%20")

    What does this bit do? And if I put vbcrlf in do I have to put it in somewhere here?
     
  6. Zack Barresse

    Zack Barresse

    Joined:
    Jul 25, 2004
    Messages:
    5,452
    Hi there,

    Maybe try vbNewLine or Chr(10) instead. I believe the "%20" is a space in HTML.

    Is that your entire sub routine, what you have posted above? There are some things with it that doesn't make sense to me, some ways you could improve it. Let us know if you'd like us to look at that.
     
  7. bomb #21

    bomb #21

    Joined:
    Jul 1, 2005
    Messages:
    8,546
    The code is a cut-down of John W's "old faithful", but maybe unfamiliar out of context. It was credited in the original thread.

    "%20" is a space in HTML.

    Neither Chr(10) nor (13) worked for me; didn't try vbNewLine.
     
  8. slurpee55

    slurpee55

    Joined:
    Oct 20, 2004
    Messages:
    7,837
    %0D is a carriage return and %0A is a line feed for Lotus Notes (and in general, and appears in this line of the code
    "' Replace carriage returns with %0D%0A (hex)
    Msg = Application.WorksheetFunction.Substitute(Msg, Space(1), "%0D%0A") "

    I believe you need to make sure that your MIME settings are for quoted-printable for this to work.
     
  9. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/755433

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice