Excel Cell Email update

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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
 

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?
 

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.
 

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?
 
Joined
Jul 25, 2004
Messages
5,458
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.
 
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.
 
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.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top