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

Automating email

Status
Not open for further replies.

gfrlaser

Programmer
May 24, 2007
67
US
I used Ramanis' code I found in the FAQ to add to a command button in my form.
The form hangs up and email is attempting to send in the backgound. I must use task manager to end the program. What can I add to this code to make it work for me?

Thanks for your help.


o=createobject("outlook.application")
oitem=o.createitem(0)
oitem.subject="Email From VFP6"

oitem.to="someone@testing.com"
** To send copy to addresses..

oitem.body="This mail was sent from vfp using Microsoft Outlook"

** To attach a file
oitem.Attachments.Add("c:\mailroom\daily.pdf")

** to send it
oitem.send

** to clear up
o=.null.
************************************
** EOF **

Thanks.
 
I checked out the above link. Thanks.

Upon copying pasting the code from berezniker's post to the command button (to edit the send, attachments etc.) I receive the following error.

"Methods and Events cannot contain nested procedures error"

Does this require to be run from a prg only as opposed to command button?
 
In the link I sent Sergey created a PRG based CLASS. Copy and paste it in some additional PRG and make sure you have SET PROCEDURE to this PRG.
Then in your Button Click you must have:
Code:
loCDOMail = CREATEOBJECT("cdo2000")
loCDOMail.cServer = ?????????
loCDOMail.nServerPort = 25 && ?????????
loCDOMail.cAttachment = [c:\mailroom\daily.pdf]
loCDOMail.Send()
Just look deeper in the code and esp. in the collection Class.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Thanks. I think I got it going ok now. Took more than I thought it was going to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top