LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Code to create Email that includes quotes

An error is raised if I try to send quotes to an email body throught code.
I've worked around this by replacing the quotes with an apostrophe, but I
was hoping someone out there knows how to pass the quotes through.

Thanks to Ron Debruin for most of the code below.
http://www.rondebruin.nl/sendmail.htm#selection

-Jeremy

-------------------------------------------------------------------------
Sub PrepareTheEmail()
Dim sRecipient As String
Dim sSubject As String
Dim sMsg As String
Dim sMail As String
Const q As String = """"
Const apos As String = "'"

With ActiveCell
sRecipient = .Offset(0, 8)
sSubject = "Regarding: " & .Offset(0, 3)
sMsg = .Offset(0, 7) & "," & vbNewLine & vbNewLine
sMsg = sMsg & "Regarding:" & vbNewLine
sMsg = sMsg & .Offset(0, 3) & vbNewLine & vbNewLine
sMsg = sMsg & "Details: " & vbNewLine
sMsg = sMsg & .Offset(0, 6) & vbNewLine & vbNewLine
sMsg = sMsg & "Solution/Comments:" & vbNewLine
sMsg = sMsg & .Offset(0, 9) & vbNewLine & vbNewLine
sMsg = sMsg & .Offset(0, 10)
End With

'Format message to work with Mail program by replacing
'spaces with %20, returns with %0D%0A, quotes with apostrophe
With Application.WorksheetFunction
sSubject = .Substitute(sSubject, " ", "%20")
sMsg = .Substitute(sMsg, " ", "%20")
sMsg = .Substitute(sMsg, vbNewLine, "%0D%0A")
sMsg = .Substitute(sMsg, vbLf, "%0D%0A")
sMsg = .Substitute(sMsg, q, apos)
End With

sMail = "mailto:" & sRecipient & _
"?subject=" & sSubject & _
"&body=" & sMsg

ThisWorkbook.FollowHyperlink sMail

End Sub
-------------------------------------------------------------------------


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Macro how to create email link for the email addresses in aRange or Selection Satish[_2_] Excel Worksheet Functions 8 December 28th 09 03:30 PM
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
How do I create an email macro to auto fill the email? Justin[_4_] Excel Discussion (Misc queries) 0 November 14th 07 10:49 PM
Create a "recap" worksheet that includes all info from all worksh. tdglaw Excel Worksheet Functions 1 February 2nd 05 04:48 PM
Scope of variable includes all Form _and_ Code modules?? John Wirt[_2_] Excel Programming 5 August 18th 03 08:27 AM


All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"