View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Q[_2_] Q[_2_] is offline
external usenet poster
 
Posts: 6
Default unexpected problem in VBA Code

Hi, below is most of my code that i am writing for an
automation email to be sent from excel. i've put the (#)
before the code for clarification purposes.

...my slight problem...

the code right now as written runs fine, its sent,
formated correctly, what i want, now line 6 & 8 are
commented, but i want them to be part of the message, but
when i uncomment them, line 13 returns an error, i cannot
for the life of me, figure out the problem, so if anyone
could help or suggest anything it would be truely
appreicated. and if you need the top part of the code
then just ask, thanks in advance.

~q

(1)Msg = Msg & "Please note that the referenced award will
expire on: " & Cells(r, 2) & vbCrLf & vbCrLf 'Insert
End Date

(2)Msg = Msg & "If you require a no-cost extension to
complete the work under this award, and" & vbCrLf

(3)Msg = Msg & "have not already requested an extension
via the ARL Business Office, please" & vbCrLf

(4)Msg = Msg & "contact the contract administrator
identified above at least three (3) weeks" & vbCrLf

(5)Msg = Msg & "end date to do so. If you have already
begun that process," & vbCrLf & vbCrLf

(6)'Msg = Msg & "please disregard this reminder." & vbCrLf

(7)Msg = Msg & "Thank you." & vbCrLf & "The Business
Office" & vbCrLf

(8)'Msg = Msg & "If you have any questions please reply to
this email."

(9)'Format URL to work with Mail program by replacing
spaces with %20 and returns with %0D%0A
Subj = Application.WorksheetFunction.Substitute
(Subj, " ", "%20")

(10)Msg = Application.WorksheetFunction.Substitute
(Msg, " ", "%20")

(11)Msg = Application.WorksheetFunction.Substitute(Msg,
vbCrLf, "%0D%0A")

(12)'Create the URL
URL = "mailto:" & email & "?subject=" & Subj & "&body=" &
Msg

(13)'Execute the URL ie. Start the Mail client
ActiveWorkbook.FollowHyperlink Address:=URL,
NewWindow:=True

(14)'Wait a few seconds ...
Application.Wait (Now + TimeValue("0:00:05"))
Application.SendKeys "%s"

(15)Next r

(16)End Sub