Article ID: 312105 - View products that this article applies to.
This article was previously published under Q312105
This article describes how to automate Microsoft Outlook 2002 to programmatically send e-mail messages from Visual FoxPro (VFP) 7.0 and later versions of Visual FoxPro, and have those messages saved in a folder other than the Sent Items folder.
VFP developers often write applications that perform bulk e-mail operations. After the messages are sent, it is sometimes desirable to save the messages to a folder other than the default Sent Items folder. In this way, the messages sent by the application are kept separate from other messages sent through the same client, making them easier to find later.
Although it is possible to programmatically specify a folder in which to save your sent e-mail messages (by using the CdoPR_SENTMAIL_ENTRYID CDO constant), the setting is ignored because the CDO (1.x) library hard-codes the value placed in the PR_SENTMAIL_ENTRYID field to the Sent Items folder. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
192083You can work around this problem by using the COPYTO() method of your e-mail message object to relocate the message to a folder of your choice before it is sent.
(http://support.microsoft.com/kb/192083/ )PRB: Setting PR_SENTMAIL_ENTRYID in CDO (1.x) is not retained
The sample code below makes a copy of the message before it is sent, as opposed to moving or copying the message after it is sent. We do this because Outlook messages are typically not sent instantly; they may sit in the Outlook Outbox for a short time. As a result, code running in a loop that relies on a message being located in the default Sent Items folder may fail.
The only drawback to this approach is that you will have a copy of the message in your alternate Sent Items folder even if the message was not successfully sent. This is not a major drawback, however, because people most often wish to retain sent messages for reference, not as proof of delivery.
Note This code was written and tested with VFP 7.0 and later versions of Visual FoxPro. With slight modification, it will work with any version of VFP. It was tested with Microsoft Outlook 2002 on a computer that is running Microsoft Office XP and Microsoft Office Outlook 2003, but should also work with Office 2000.
The VFP 7.0 code below will do the following:
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
Article ID: 312105 - Last Review: November 23, 2006 - Revision: 3.5
Contact us for more help