Re: Using ShellExec to Invoke an Outgoing E-Mail Message

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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-between
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,
rather
than having each line of text on its own line in the body. How can I
resolve
this? How can I get the body of the message to appear as though I had
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
you
of a Phase 1 creation for the specified plant. Details of the Phase 1 are
included below:" & vbCrLf & vbCrLf
strBody = strBody & "Phase Number: " &
Form_frmEventCreate.txtPhaseNumber
& 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


.



Relevant Pages

  • Re: emailing from excel with Thundrbird
    ... email client is thunderbird. ... ShellExecute 0&, vbNullString, _ ... Private Declare Function ShellExecute Lib "shell32.dll" _ ... ByVal lpOperation As String, _ ...
    (microsoft.public.excel.misc)
  • Re: Plain text email?
    ... def Mail: #data is string of text ... Inkiniteo wrote: ... > avoid the convertion to HTML by the email client or Gmail, ...
    (comp.lang.python)
  • Re: sending mail
    ... I have an example using the default email client on my web site if this is ... string subject = "Love the Program"; ... string body = "Thanks a lot"; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: MIME::QuotedPrint - extra = and linebreak?
    ... string I was encoding. ... the encoded string, though. ... removing the final '=' does now produce subject headers that display ... When sending a long subject header via a sendmail pipe, that code makes at least my email client happy... ...
    (perl.beginners)
  • Re: Junk in in-box
    ... Howard Brazee wrote: ... junk mailbox", ... It would help if we knew what email client you're using. ... the text string he gave (assuming, of course, he actually gave the ...
    (comp.sys.mac.apps)