I'm happy with Jmail.dll, the free version.
You can find it here:
www.dimac.net
Go to Free Downloads and download w3Jmail
The installation program extract some files, but the only necessary piece is
jmail.dll.
Attached the function I have wrapped around it.
Jmail can manage smtp authentication, also with a complete email as user name.
The latter is managed in a special way in my code.
To use smtp authentication specify the smtp server prefaced with username and
password
in the following way:
Normal smtp server: mai.libero.it
Auth smpt server sample 1: io_gianni:[EMAIL PROTECTED]
Auth smpt server sample 2: [EMAIL PROTECTED]:[EMAIL PROTECTED]
Sample use:
m.server = "smtp.fastwebnet.it"
m.sender = "[EMAIL PROTECTED]"
m.address = "[EMAIL PROTECTED]"
m.subject = "Test Email"
m.body = "A very short body ...:)"
m.attachment = "fileattached.zip"
m.receipt_requested = .t.
m.success = S_EMAIL(m.server, m.sender, m.address, m.subject, m.body,
m.attachment, m.receipt_requested)
HTH, Gianni
*********************************** Code begin here
*FUNCTION S_EMAIL
parameters m.pp_server, m.pp_sender, m.pp_address, m.pp_subject, m.pp_body,
m.pp_attachment, m.pp_receipt_requested
if ! file("JMAIL.DLL")
wait window "JMAIL NON installato"
RETURN .f.
endif
if ! empty(m.pp_server) and occurs("@", m.pp_server) > 1
* "[EMAIL PROTECTED]:[EMAIL PROTECTED]"
RETURN L_S_EMAIL02()
endif
local s_MailMessage, llExecuted
if type("s_MailMessage") # "O" or isnull(s_MailMessage)
local m.riprova, m.errore
m.riprova = .t.
m.errore = .f.
do while m.riprova
try
s_MailMessage = newobject("JMail.SMTPMail")
m.riprova = .f.
catch
try
=DO_RUN("REGSVR32.EXE /s JMAIL.DLL")
catch
m.riprova = .f.
m.errore = .t.
endtry
endtry
enddo
if m.errore
wait window "Impossibile registrare JMAIL.DLL"
RETURN .f.
endif
endif
with s_MailMessage
.Logging = .t.
.ISOEncodeHeaders = .f.
if ! empty(m.pp_server)
.ServerAddress = m.pp_server
endif
if type("pp_sender[1]") = "C"
external array pp_sender
.Sender = pp_sender[1, 1]
.SenderName = left(.Sender, at("@", .Sender) -1)
if alen(pp_sender, 2) = 2
.SenderName = pp_sender[1, 2]
endif
else
.Sender = m.pp_sender
.SenderName = left(.Sender, at("@", .Sender) -1)
endif
if ! empty(m.pp_subject)
.Subject = alltrim(m.pp_subject)
else
* BUG! BUG! BUG!
* PER EVITARE CHE VENGA ELIMINATO COMPLETAMENTE IL CAMPO
"SUBJECT" DALL'EMAIL
* CHE IN CASO DI RICHIESTA DI CONFERMA DI LETTURA PRODUCE
* L'ERRORE "IMPOSSIBILE INVIARE LA CONFERMA" IN OUTLOOK EXPRESS
.Subject = " "
endif
.Body = alltrim(m.pp_body)
.ReturnReceipt = m.pp_receipt_requested
if m.pp_receipt_requested
* AGGIUNTO PER OFFICE OUTLOOK CHE NON RICONOSCE
Return-Receipt-To
* CHE INVECE OUTLOOK EXPRESS RICONOSCE TRANQUILLAMENTE
.AddNativeHeader("Disposition-Notification-To", '"' +
.SenderName + '" <' + .Sender + ">")
endif
.AddNativeHeader("X-Mailer", "Microsoft Outlook Express 6.00.2900.2670")
.AddNativeHeader("X-MimeOLE", "Produced By Microsoft MimeOLE
V6.00.2900.2670")
if type("pp_address[1]") = "C"
external array pp_address
local lnRows, lnColumns, lnIndex, lcAddress, lcDisplayName,
lcType
lnRows = alen(pp_address, 1)
lnColumns = alen(pp_address, 2)
for lnIndex = 1 to lnRows
if lnColumns = 0
lcAddress = pp_address[lnIndex]
else
lcAddress = pp_address[lnIndex, 1]
endif
lcDisplayName = left(lcAddress, at("@", lcAddress) -1)
lcType = "TO"
if lnColumns >= 2
lcDisplayName = pp_address[lnIndex, 2]
endif
if lnColumns >= 3
lcType = pp_address[lnIndex, 3]
endif
do case
case lcType == "TO"
.AddRecipientEx(lcAddress, lcDisplayName)
case lcType == "CC"
.AddRecipientCC(lcAddress)
case lcType == "BCC"
.AddRecipientBCC(lcAddress)
endcase
endfor
else
.AddRecipientEx(m.pp_address, left(m.pp_address, at("@",
m.pp_address) -1))
endif
if type("pp_attachment[1]") = "C"
external array pp_attachment
local lnRows, lnColumns, lnIndex, lcPathname, lcName
lnRows = alen(pp_attachment, 1)
lnColumns = alen(pp_attachment, 2)
for lnIndex = 1 to lnRows
if lnColumns = 0
lcPathname = pp_attachment[lnIndex]
else
lcPathname = pp_attachment[lnIndex, 1]
endif
lcName = STRIPPATH(lcPathname)
if lnColumns >= 2
lcName = pp_attachment[lnIndex, 2]
endif
if file(lcPathname)
.AddAttachment(lcPathname)
endif
endfor
else
if ! empty(m.pp_attachment) and file(m.pp_attachment)
.AddAttachment(m.pp_attachment)
endif
endif
.Silent = .t.
llExecuted = .Execute()
if ! llExecuted
local lcMsg
lcMsg = ;
"Invio email NON riuscito!" + chr(13) + chr(10) +
chr(13) + chr(10) + ;
iif(.ErrorCode # 0, ltrim(str(.ErrorCode)) + " " +
.ErrorMessage + " " + .ErrorSource + "." + chr(13) + chr(10) + chr(13) +
chr(10), "") + ;
.Log
wait window lcMsg
endif
if llExecuted
.Close
endif
endwith
RETURN llExecuted
*
FUNCTION L_S_EMAIL02
local s_MailMessage, llExecuted
if type("s_MailMessage") # "O" or isnull(s_MailMessage)
local m.riprova, m.errore
m.riprova = .t.
m.errore = .f.
do while m.riprova
try
s_MailMessage = newobject("JMail.Message")
m.riprova = .f.
catch
try
=DO_RUN("REGSVR32.EXE /s JMAIL.DLL")
catch
m.riprova = .f.
m.errore = .t.
endtry
endtry
enddo
if m.errore
wait window "Impossibile registrare JMAIL.DLL"
RETURN .f.
endif
endif
local m.server, m.auth_name, m.auth_pw
m.server = m.pp_server
m.auth_name = ""
m.auth_pw = ""
if ! empty(m.server) and occurs("@", m.server) > 1
* "[EMAIL PROTECTED]:[EMAIL PROTECTED]"
m.auth_name = left(m.server, at(":", m.server) -1)
m.server = substr(m.server, at(":", m.server) +1)
m.auth_pw = left(m.server, at("@", m.server) -1)
m.server = substr(m.server, at("@", m.server) +1)
endif
with s_MailMessage
.Logging = .t.
.ISOEncodeHeaders = .f.
if type("pp_sender[1]") = "C"
external array pp_sender
.From = pp_sender[1, 1]
.FromName = left(.From, at("@", .From) -1)
if alen(pp_sender, 2) = 2
.FromName = pp_sender[1, 2]
endif
else
.From = m.pp_sender
.FromName = left(.From, at("@", .From) -1)
endif
if ! empty(m.pp_subject)
.Subject = alltrim(m.pp_subject)
else
* BUG! BUG! BUG!
* PER EVITARE CHE VENGA ELIMINATO COMPLETAMENTE IL CAMPO
"SUBJECT" DALL'EMAIL
* CHE IN CASO DI RICHIESTA DI CONFERMA DI LETTURA PRODUCE
* L'ERRORE "IMPOSSIBILE INVIARE LA CONFERMA" IN OUTLOOK EXPRESS
.Subject = " "
endif
.Body = alltrim(m.pp_body)
.ReturnReceipt = m.pp_receipt_requested
if m.pp_receipt_requested
* AGGIUNTO PER OFFICE OUTLOOK CHE NON RICONOSCE
Return-Receipt-To
* CHE INVECE OUTLOOK EXPRESS RICONOSCE TRANQUILLAMENTE
.AddNativeHeader("Disposition-Notification-To", '"' + .FromName
+ '" <' + .From + ">")
endif
.AddNativeHeader("X-Mailer", "Microsoft Outlook Express 6.00.2900.2670")
.AddNativeHeader("X-MimeOLE", "Produced By Microsoft MimeOLE
V6.00.2900.2670")
if type("pp_address[1]") = "C"
external array pp_address
local lnRows, lnColumns, lnIndex, lcAddress, lcDisplayName,
lcType
lnRows = alen(pp_address, 1)
lnColumns = alen(pp_address, 2)
for lnIndex = 1 to lnRows
if lnColumns = 0
lcAddress = pp_address[lnIndex]
else
lcAddress = pp_address[lnIndex, 1]
endif
lcDisplayName = left(lcAddress, at("@", lcAddress) -1)
lcType = "TO"
if lnColumns >= 2
lcDisplayName = pp_address[lnIndex, 2]
endif
if lnColumns >= 3
lcType = pp_address[lnIndex, 3]
endif
do case
case lcType == "TO"
.AddRecipient(lcAddress, lcDisplayName)
case lcType == "CC"
.AddRecipientCC(lcAddress)
case lcType == "BCC"
.AddRecipientBCC(lcAddress)
endcase
endfor
else
.AddRecipient(m.pp_address, left(m.pp_address, at("@",
m.pp_address) -1))
endif
if type("pp_attachment[1]") = "C"
external array pp_attachment
local lnRows, lnColumns, lnIndex, lcPathname, lcName
lnRows = alen(pp_attachment, 1)
lnColumns = alen(pp_attachment, 2)
for lnIndex = 1 to lnRows
if lnColumns = 0
lcPathname = pp_attachment[lnIndex]
else
lcPathname = pp_attachment[lnIndex, 1]
endif
lcName = STRIPPATH(lcPathname)
if lnColumns >= 2
lcName = pp_attachment[lnIndex, 2]
endif
if file(lcPathname)
.AddAttachment(lcPathname)
endif
endfor
else
if ! empty(m.pp_attachment) and file(m.pp_attachment)
.AddAttachment(m.pp_attachment)
endif
endif
.Silent = .t.
if ! empty(m.auth_name) and ! empty(m.auth_pw)
.MailServerUserName = m.auth_name
.MailServerPassWord = m.auth_pw
endif
if ! empty(m.server)
llExecuted = .Send(m.server)
else
llExecuted = .Send()
endif
if ! llExecuted
local lcMsg
lcMsg = ;
"Invio email NON riuscito!" + chr(13) + chr(10) +
chr(13) + chr(10) + ;
iif(.ErrorCode # 0, ltrim(str(.ErrorCode)) + " " +
.ErrorMessage + " " + .ErrorSource + "." + chr(13) + chr(10) + chr(13) +
chr(10), "") + ;
.Log
wait window lcMsg
endif
if llExecuted
.Close
endif
endwith
RETURN llExecuted
*
*********************************** Code end here
----- Original Message -----
From: "Whil Hentzen (Pro*)" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Thu, 05 Apr 2007 11:52:39 -0500
Subject: Sending mail from VFP w/o mailto
Hi folks,
I have inherited (ahem...) an app that includes a rudimentary email
function in one of its modules. It uses the 'mailto' and shellexecute
functions in Windows, primarily because the app used to be x-plat and
thus couldn't rely on Windows-only solutions.
The Windows part of the call looks like this:
m.mailcommand = "mailto:" + m.realname + "<" + m.emailaddress + ">" +
"?subject=" + m.subject + "&body=" + m.message
declare integer ShellExecute in shell32.dll...
declare integer FindWindow in WIN32API...
=ShellExecute(FindWindow(....))
It works fine for short messages (@1000 bytes), but now they want to
send big ol' messages, like 10K to 20K. This current mechanism is
truncating those messages (I think at 1024.)
My options are...
Door #1: Find a way to use the current mechanism but allow it to use
much longer messages -> that's your first question.
Door #2: Find a different, Windows OS-only solution.
Door #3: Incorporate a third party utility such as BLAT (which I've seen
talked about here oodles) or ipstuff.
It'd be great if I could just alter the syntax of the current mechanism
to be able to include longer messages, but I don't know enough about how
that works to determine if it's a native limit or something artificial
imposed by this app.
Whil
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.