Re: Using ShellExec to Invoke an Outgoing E-Mail Message
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Sep 2006 16:32:23 +0100
Although the mailto: protocol is a clean and simple way of launching the
default email client, and avoids getting into different object models and
portability, it is not without its problems.
For instance, it can only set your default 'From' address. Although the RFC
822 suggests that &From/&Sender are valid, RFC 2368 suggests these generate
"unsafe headers". I don't really understand this since it is launching an
email client rather than sending unconditionally, and the email client can
validate the address is legal for your "identity"
Also, I've noticed that the "mailto:" protocol cannot send a Euro symbol in
the body of an email, although it can send it in the subject. You just get
"?" character in the body, whether it's encoded in the URL as %80 or not.
It's odd because other 8-bit characters seem OK. I suspect the problem is
that, somewhere along the way, the character set is quietly changed from
Windows 1252 (where Euro is at hex 80) to iso-8859-1 (where there's no
Euro). This is one of the few subtle differences between those sets. If
anyone has a workaround for this, I'd be glad to hear it
Tony Proctor
"John R. Dougherty" <JohnRDougherty@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:C1645D7F-460F-4A7E-9913-5700213D5ADF@xxxxxxxxxxxxxxxx
In VB6, I am using the ShellExec API to create an outgoing E-Mail message.I
am passing in the body of the text with the "vbCrLf" separator in-betweenrather
each line of text that I want to show in the E-Mail. However, when the
Outlook message pops up, the body text has everything pushed together,
than having each line of text on its own line in the body. How can Iresolve
this? How can I get the body of the message to appear as though I hadyou
pressed enter at the end of each line?
Here is a snippet of my code:
strEMails = ""
For z = 1 To Me.lstAutoEMailUsers.ListCount
strEMails = strEMails & lstAutoEMailUsers.ItemData(z - 1) & ","
Next z
strEMails = strEMails & txtEmailExtraUsers
strSubject = "Phase 1 Created for Plant " &
Form_frmEventCreate.cboPlantNumber
strBody = "The DFA Computerized Phase System is configured to notify
of a Phase 1 creation for the specified plant. Details of the Phase 1 areForm_frmEventCreate.txtPhaseNumber
included below:" & vbCrLf & vbCrLf
strBody = strBody & "Phase Number: " &
& vbCrLf
strBody = strBody & "Product Pack Code: " &
Form_frmEventCreate.cboPackCode & vbCrLf
blnSentEMail = modGeneral.blnOpenEMail(strEMails, strSubject, strBody)
Public Function blnOpenEMail(ByVal strEmailAddress As String, Optional
strSubject As String, Optional strBody As String) As Boolean
'== Purpose: sends an E-Mail message using the default E-Mail client
currently on the host PC
'== Author: John R. Dougherty
'== Created: 08-31-2006
'== Modified:
'== Notes:
'== -----------------------------------------------------------------
Dim lngWindow As Long
Dim lngRet As Long
Dim strParams As String
strParams = strEmailAddress
If LCase$(Left$(strParams, 7)) <> "mailto:" Then
strParams = "mailto:" & strParams
End If
If strSubject <> "" Then
strParams = strParams & "?subject=" & strSubject
End If
If strBody <> "" Then
strParams = strParams & IIf(strSubject = "", "?", "&")
strParams = strParams & "body=" & strBody
End If
lngRet = ShellExecute(lngWindow, "open", strParams, vbNullString,
vbNullString, 5)
- Thanks,
JRD
.
- Follow-Ups:
- Re: Using ShellExec to Invoke an Outgoing E-Mail Message
- From: Mike D Sutton
- Re: Using ShellExec to Invoke an Outgoing E-Mail Message
- References:
- Using ShellExec to Invoke an Outgoing E-Mail Message
- From: John R. Dougherty
- Using ShellExec to Invoke an Outgoing E-Mail Message
- Prev by Date: Re: Limit the size of an application's window.
- Next by Date: Re: Using ShellExec to Invoke an Outgoing E-Mail Message
- Previous by thread: Re: Using ShellExec to Invoke an Outgoing E-Mail Message
- Next by thread: Re: Using ShellExec to Invoke an Outgoing E-Mail Message
- Index(es):
Relevant Pages
|