Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Miguel Sarria
  Where is Miguel Sarria?
 New Mexico - United States
 Miguel Sarria
 To: Paul Michael
  Where is Paul Michael?
 Connecticut - United States
 Paul Michael
Subject: RE: Sending email via VFP 6.0
Thread ID: 21606 Message ID: 56991 # Views: 2 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Thursday, December 2, 2004 7:22:34 PM         

VFP email has these 3 messages when this code is run:

PRIVATE objsession, objmessage, objrecip, lctarget, lcservername, lcnumusers, lcnumproj

lcservername = 'None'
IF USED('system')
lcnumusers = 0
IF USED('users')
lcnumusers = RECCOUNT('users')
lcnumproj = 0
IF USED('projects')
lcnumproj = RECCOUNT('projects')

lctarget = 'miguel@ccfpro.com' && Sending all to myself
objsession = CREATEOBJECT("mapi.session")

*-- Window message “Choose Prifile”
*-- Profile Nme: Outlook
*-- etc.

objmessage = objsession.outbox.MESSAGES.ADD
objmessage.subject = "CCFPro Setup"

objmessage.TEXT = ;
"Server: "+ lcservername +CHR(13)+;
"Number of Users: "+ TRANSFORM(lcnumusers,'999,999,999')+CHR(13)+;
"Number of Projects: "+ TRANSFORM(lcnumproj,'999,999,999')+CHR(13)+;
"Package date :"+ TRANSFORM(DATE(),'@YL')+CHR(13)+ "From CCFPro"

* Add Recipient
objrecip = objmessage.recipients.ADD(lctarget)


*-- Window message “Microsoft Office Outlook”
*-- A program is trying to access e-mail addresses you have stored etc.

* Send it

*-- Window message “Microsoft Office Outlook”
*-- A program is trying to automatically send e-mail on your behalf. It may be a Virus etc.

objmessage = .NULL.
objrecip = .NULL.

How do you sent an email without this interruption?

Best regards, Miguel

> Hello all:
> Heres some history:
> The existing Program (named Arrival) receives & Delivers packages and has email Notification built in. After the package is Posted, an email will get sent, may it be Lotus, Express or Outlook, depending how it's configured in Arrival. The problem is, if the user wants to send another email notifying that their employee that their package is still in receiving, they have no way in doing this. So, I created a small VFP email program and say in 30 days the customer wants to notify their employees again, they can launch the program and what I want to happen is ONLY the packages that were not receive (ref. pakgstatus='n'), they can select and click send hence, sending an email with the required data in it's body, pop it into Outlook 2000 'Outbox'. Also the capibitly they can select All the records and when pressing send indiviually emails get sent to outlook. Foe example, user selects/highlights 20 records from the grid and presses send, they will then see 20 seperate emails in their Outlook 2000 Outbox. So I took a stab at it. Coded my send button, launched program, click send, My form/grid appeared showing the only the records with an 'N' for it's status good. close out that form (ref. clicking the 'x') and moments later a VFP 6.0 App error = Address OOOXXX...... "Memory could not be written". I looked in my Outlook 2000 Outbox and saw nothing. I have a profile in Outlook calles 'testmail' using the 'personnal folders' service.
> Thank you,
> PM
> &&Code:
> Create Cursor testmail (pakgstatus c(1), packnumber i, pdate d)
> For ix=1 To 100
> Insert Into testmail Values ;
> (Chr(Asc('a')-1+Ceiling(Rand()*26)), ix, Date()-ix)
> Endfor
> Browse For pakgstatus = 'n' && Would email these
> Local objSession, objMessage, objRecip, lcTarget
> lcTarget = 'pm007_@email.com' && Sending all to myself
> objSession = Createobject("mapi.session")
> objSession.Logon
> Select testmail
> Scan For pakgstatus = 'n' && Would email these
> objMessage = objSession.Outbox.Messages.Add
> objMessage.Subject = "Notification"
> objMessage.Text = ;
> "Package Number: "+ Transform(packnumber)+Chr(13)+;
> "Package date :" + Transform(pdate,'@YL')+Chr(13)+;
> "Best Regards"
> * Add Recipient
> objRecip = objMessage.Recipients.Add(lcTarget)
> objRecip.Resolve
> * Send it
> objMessage.Send
> objMessage = .Null.
> objRecip = .Null.
> Endscan
> objSession.Logoff



Sending email via VFP 6.0 Posted by Paul Michael @ 3/26/2003 7:09:34 PM
RE: Sending email via VFP 6.0 Posted by Miguel Sarria @ 12/2/2004 7:22:34 PM