Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VFP and Outlook integration

250 views
Skip to first unread message

Ginny Bonish

unread,
Jan 26, 2000, 3:00:00 AM1/26/00
to
Say I have an email address and some other info in a VFP dbf. From a
form, I want the user to hit a button which will create a new email
message in Outlook and populate the TO: field with the email address,
and maybe build the body of the message from the foxpro data.

Any ideas?

Thanks

Ginny


John Dobson

unread,
Jan 26, 2000, 3:00:00 AM1/26/00
to
There are a couple of ways that I can think of to do this. If you aren't
using Outlook Express, then you could use CDO. Look in the MSDN library
under messaging services for the object model. it's wuite simple. Another
option would be to use something like the SMTP class in wwIPStuff.vcx which
can be obtained from the www.west-wind.com website. If you are using Outlook
Express, then the Mapi controls are probably you best bet.

HTH

John

Ginny Bonish <gbo...@infonet.tufts.edu> wrote in message
news:388F08D5...@infonet.tufts.edu...

Ginny Bonish

unread,
Jan 26, 2000, 3:00:00 AM1/26/00
to
John,

Thanks for your ideas. I looked up CDO and could only find how to use the
Multi-calendar viewer with CDO. You said it was quite simple - can you tell me
how to do it?

Thanks for your help

paula berg

unread,
Jan 26, 2000, 3:00:00 AM1/26/00
to
Ginny,

You COULD use CDO, but it's much easier (although "easier" is relative) to use
MAPI. There's plenty of documentation on M$'s site about MAPI, but essentially you
need an established profile (which you can set up through Outlook) and then your
code will look something like the following:

on error do MapiError with MapiReturnCode

objSession = CreateObject("MAPI.Session")
objSession.logon(Mail_ProfileName)

if MapiReturnCode = .t. then
* "Error establishing session"
*...provide an On Error routine that you can test for an error establishing the
session
endif

select messageDBF && wherever your mail resides

* for each message you want to send, do the following:
objMessage = objSession.Outbox.Messages.Add && create an outbox entry

*____________ Populate the Subject and message
objMessage.Subject = "subject..."
objMessage.Text = "text of message..."

*if you want to handle multiple recipients, there will be one of the following
for each recip...
objRecip = objMessage.Recipients.add
objRecip.name = xName && recip's full email address

* You can also use Outlook's address book to resolve names if you want to; the
code here assumes you have the email address

objRecip.Type = 1
objRecip.Resolve
objMessage.Update
objMessage.Send(1, 0, 0) && puts copy of message in sent folder after it's sent


The preceding code puts a message into Outlook's outbox, but doesn't send it. (It
will be sent whenever Outlook is goosed to send outgoing mail.) If you want to
force Outlook to do the send programmatically, you will have to write a VBS script
that you execute from within FoxPro. The script essentially mimics the keystrokes
that you would use to force Outlook to get and send mail immediately.

There's a ton of documentation on MAPI on MSDN and M$'s knowledgebase. Good luck

Tony MIller

unread,
Jan 26, 2000, 3:00:00 AM1/26/00
to
Look again at Mr. Hravey's website, he has code examples for this I
believe..

paula berg wrote in message <388F656C...@princetoncyber.com>...

John Dobson

unread,
Jan 27, 2000, 3:00:00 AM1/27/00
to
Here's an example showing how to do it with CDO.

LOCAL loSession
loSession = CREATEOBJECT("mapi.session")
loSession.Logon(your mapi profile goes in here) && this is stored in the
registry under HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows Messaging Subsystem\Profiles
for NT. I don't remember the key for Win 98, but you should be able to find
it easily enough.

LOCAL loNew
loNew = loSession.Outbox.MESSAGES.ADD()
loNew.Subject = "Message With Error"
lcMessageText = CRLF + "Message File Attached" + CRLF
loNew.TEXT = lcMessageText
LOCAL loAttach
loAttach = loNew.Attachments.ADD()
loAttach.TYPE = 1
loAttach.SOURCE = FULLPATH("somefilename")

LOCAL loSendTo
loSendTo = loNew.Recipients.ADD()
loSendTo.NAME = "fr...@someaddress.com"
loSendTo.TYPE = 1
loSendTo.Resolve()

loNew.UPDATE()

loNew.SEND(1,0,0)

loSession.Logoff()

MESSAGEBOX("Message Sent", MB_OK+MB_ICONINFORMATION, _SCREEN.CAPTION)

RELEASE ALL LIKE lo*

To find CDO in MSDN, look under platform SDK and Messaging and Collaboration
Services.

HTH

John


Ginny Bonish <gbo...@infonet.tufts.edu> wrote in message

news:388F27C9...@infonet.tufts.edu...

John Harvey

unread,
Jan 27, 2000, 3:00:00 AM1/27/00
to
If you're wanting to integrate with Outlook, look at the samples on my
website. If you want to just send email, look at Rick Strahl's wwipstuff -
www.west-wind.com . It allows you to send attachments also. Great product.


--
John Harvey
http://home.att.net/~john.harvey/vfpstuff.htm

no_carrier

unread,
Jan 27, 2000, 3:00:00 AM1/27/00
to
Here is one example without cdo
This one creates a tast, but just look up the Getdefaultfolder for the email
folder 6 is for task in outlook
I took this from some code I wrote a little while ago, and cant recall off
the top of my head what folder email is in ....
m_sendtop=replu(proj.sls) && a lookup for a name function I wrote.
ol = newOBJECT("Outlook.Application")
ns = ol.GetNamespace("MAPI")
oFolder = ns.GetDefaultfolder(6) && correct this for correct folder...
itmtask=ol.createItem(0) && makes a new item
m_duedate=date()+1
m_remindertime=m_duedate
with itmtask
.subject="Project Update:"+alltrim(proj.pname)
.body=lcmessagetext
*.duedate=m_duedate
*.remindertime=m_remindertime
.save
endwith
objrecip=itmtask.recipients.add(m_sendtop)
objrecip.resolve
itmtask.display && this brings up and shows the outlook item.

I hope this help.s
Bob

John Dobson <dob...@asm.orguk> wrote in message
news:Or#65OKa$GA.1908@cppssbbsa06...

0 new messages