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
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