Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent, can't add string to Outlook Express email

Status
Not open for further replies.

SgtPepps

IS-IT--Management
May 1, 2002
109
GB
I found some code on these forums, it worked well until it started to crash excel. It crashes on the line starting "ShellExecute", i'm wondering if the string is too big. Please help as this project is urgent!

Thankyou in advance

SgtPepps

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
Dim emlUserName As String

Sub Procedure()

emlUserName = CreateObject("Wscript.Network").UserName

'Get the email address
Email = "user@company.com"

'Message subject
Subj = "Update from" & emlUserName

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

'Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%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

'Wait two seconds before sending keystrokes
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"

End Sub
 
I've found a work around, I just reduce the amount of Spaces and Carridge Returns in the string. Although an answer to the above problem would be nice, it is no longer urgent.

Regards

SgtPepps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top