View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mike[_111_] Mike[_111_] is offline
external usenet poster
 
Posts: 27
Default Help Using Excel 2003 to send emails

This piece of code worked fine when I was on Office 2000. Now I've
upgraded to 2003 I am struggling with the below if the length of
lsMailTo is longer than 1033 characters (what a strange number)

psBody = "Hello " & gsFirstName & vbCr & vbCr & psBody & _
vbCr & vbCr & "Regards,"

lsMailTo = _
"mailto:" & gsEmailAdd & _
"?subject=" & HexString(gsSubject) & _
"&body=" & HexString(psBody)


ActiveWorkbook.FollowHyperlink lsMailTo


Function HexString(psStr) As String

Dim liIndex As Long
Dim lsChar As String
Dim lsHex As String


For liIndex = 1 To Len(psStr)
lsChar = Mid(psStr, liIndex, 1)

If IsNumeric(lsChar) Or IsChar(lsChar) Then
HexString = HexString + lsChar
Else
lsHex = Hex(Asc(lsChar))

If Len(lsHex) = 1 Then
lsHex = "0" & lsHex
End If

HexString = HexString + "%" + lsHex
End If
Next

End Function


My code is probably overkilling which characters need to be converted to
hex (e.g. a comma would definately cause a run time error) but I am
curious to get this working please

--
Mike News