Recently, I received the below code as a solution to emailing word documents created in VisualFoxPro from existing reports.
Also let me say thanks to danceman, mgagnon and rgbean for their quick reponse and help.
MAPI control
with MAPIMessages1
.AttachmentIndex = 0
.AttachmentPosition = 0
.AttachmentPathName = ("c:\test1.txt"
.AttachmentIndex = 1
.AttachmentPosition = 1
.AttachmentPathName = ("c:\test2.txt"
endwith
My problem, since I am very new at this, how does that work exactly? Currently we use the below code to email a single attachment.
*************************************
procedure deliver_mail
if empty(m.subject) .or. empty(m.text) .or. empty(m.recipient)
wait window "Missing Email Header Data... Program Will Exit" timeout 1
return
else
***** Memory Variable Setup For Automatic Email ***********************
mprofile = "Microsoft Outlook" && Email Profile
***** m.subject = 'Visual Foxpro Automatic Mail' && Email Subject
***** m.text = 'This is a automatic email' && Email Information
***** m.recipient = 'Smith, John' && Who to send the Email to
***** m.attachment = 'l:\vfpmail.prg' && Email File Attachment
***********************************************************************
***********************************************************************
*Create a MAPI Session object then Logon. The Logon dialog can be
*bypassed by providing a valid ProfileName as the first parameter
*(as a string) to the Logon Method as seen below.
objSession = CREATEOBJECT("mapi.session"
objSession.Logon(mprofile)
*Create a new message in the Outbox and populate a few basic properties
objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = m.subject
objMessage.Text = m.text
*Add an attachment (assumes "myfile.doc" exist in c:\)
if empty(m.attachment)
Wait Window " No Attachment To Send...." nowait
else
Wait Window "Attachment Will Be Sent...." nowait
objMessage.Attachments.Add(m.attachment, 0, 1, m.attachment)
endif
*Add a Recipient to the message we just created and resolve
objRecip = objMessage.Recipients.Add(m.recipient) && who it's to
objRecip.Resolve
*Send it
objMessage.Send
*Clean up then bail
objSession.Logoff
RELEASE objRecip, objMessage, objSession
endif
Also let me say thanks to danceman, mgagnon and rgbean for their quick reponse and help.
MAPI control
with MAPIMessages1
.AttachmentIndex = 0
.AttachmentPosition = 0
.AttachmentPathName = ("c:\test1.txt"
.AttachmentIndex = 1
.AttachmentPosition = 1
.AttachmentPathName = ("c:\test2.txt"
endwith
My problem, since I am very new at this, how does that work exactly? Currently we use the below code to email a single attachment.
*************************************
procedure deliver_mail
if empty(m.subject) .or. empty(m.text) .or. empty(m.recipient)
wait window "Missing Email Header Data... Program Will Exit" timeout 1
return
else
***** Memory Variable Setup For Automatic Email ***********************
mprofile = "Microsoft Outlook" && Email Profile
***** m.subject = 'Visual Foxpro Automatic Mail' && Email Subject
***** m.text = 'This is a automatic email' && Email Information
***** m.recipient = 'Smith, John' && Who to send the Email to
***** m.attachment = 'l:\vfpmail.prg' && Email File Attachment
***********************************************************************
***********************************************************************
*Create a MAPI Session object then Logon. The Logon dialog can be
*bypassed by providing a valid ProfileName as the first parameter
*(as a string) to the Logon Method as seen below.
objSession = CREATEOBJECT("mapi.session"
objSession.Logon(mprofile)
*Create a new message in the Outbox and populate a few basic properties
objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = m.subject
objMessage.Text = m.text
*Add an attachment (assumes "myfile.doc" exist in c:\)
if empty(m.attachment)
Wait Window " No Attachment To Send...." nowait
else
Wait Window "Attachment Will Be Sent...." nowait
objMessage.Attachments.Add(m.attachment, 0, 1, m.attachment)
endif
*Add a Recipient to the message we just created and resolve
objRecip = objMessage.Recipients.Add(m.recipient) && who it's to
objRecip.Resolve
*Send it
objMessage.Send
*Clean up then bail
objSession.Logoff
RELEASE objRecip, objMessage, objSession
endif