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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send e-mail with attachment from VFP?

Status
Not open for further replies.

timmappa

Programmer
Jan 21, 2001
20
0
0
AU
Hi,

How to send e-mail with attachment automatically from VFP. I use Microsoft outlook. Please help.

Thanks
Tim

 

faq184-3894


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
foxdbs

JMail, COM server, freeware to send mails

I dont' see anywhere on the website that this product works with outlook as the request was.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I'm sorry, I haven't understand that it is necessary to send mails using Outlook. If so, solution is Outlook automation (example bellow). JMail sends mails directly to the SMTP server, no e-mail client is required.

<code>
* Class requires .roOutLook and .roOutLookItem properties

PROCEDURE SendMailOutlook
LPARAMETERS tcMsgSubject, tcMsgNoteText, ;
tnRecipients, taRecipients, ;
tnAttachments, taAttachments, ;
tcFromMail, tcFromName, ;
tcUserName, tcPassWord, ;
tlShowClient

EXTERNAL ARRAY taRecipients, taAttachments

LOCAL lni, llProblem

THIS.roOutLook = NEWOBJECT( 'Outlook.Application' )
IF TYPE('THIS.roOutLook')='O' AND NOT ISNULL(THIS.roOutLook)
THIS.roOutLookItem = THIS.roOutLook.CreateItem( 0 )

WITH THIS.roOutLookItem
.Subject = m.tcMsgSubject
.Body = m.tcMsgNoteText

STORE '' TO .To, .Cc, .BCc
FOR lni=1 TO m.tnRecipients
DO CASE
CASE taRecipients[m.lni,2]=1 && standard
.To = IIF( EMPTY( .To ), '', .To+';' )+taRecipients[m.lni,1]
CASE taRecipients[m.lni,2]=2 && CC
.Cc = IIF( EMPTY( .Cc ), '', .Cc+';' )+taRecipients[m.lni,1]
CASE taRecipients[m.lni,2]=3 && BCC
.Bcc = IIF( EMPTY( .Bcc ), '', .Bcc+';' )+taRecipients[m.lni,1]
ENDCASE
ENDFOR

FOR lni=1 TO m.tnAttachments
.Attachments.Add( taAttachments[m.lni], 1 )
&& with ,1: portal.dfpug.de/dFPUG/Dokumente/Konferenzen/VFP-Konferenz%202002/47_D-IUPD.pdf
&& without ,1: ENDFOR
.Send()
ENDWITH
THIS.roOutLookItem = NULL
ELSE
llProblem = .T.
ENDIF
RETURN NOT m.llProblem
</code>
 
I use the following code in many of my programs. It is very simple and works fine. The only negative is that outlook needs to be running on the client.

******Generate e-mail

o=createobject("outlook.application")
oitem=o.createitem(0)
oitem.subject="Enter Subject Text"
oitem.to="emailname@emailaddress"
oitem.cc="emailname@emailaddress"
oitem.body="Enter message text"
oitem.attachments.add("drive letter:\directory\file name")

oitem.send

o=.null.
 
I understand you're looking for an Outlook solution, but if that requirement changes, you will definitely want to look at the free BLAT.DLL which can be installed without registration.

BLAT.DLL is a 100K file that provides a complete mix of SMTP capabilities including text/html email, multiple attachments, with support a for a variety of authentication and encoding schemes. BLAT is available at There's also a free, active, and very helpful Blat speecific newsgroup up on Yahoo. Worth participating in while you get your feet wet with Blat.

Good-luck!
Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top