Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2003, 09:38 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Outlook 2000 VBA - Receive mail...

I have been using "Outlook 2000 VBA" for the last couple of years and developed various applications to enhance my version of Outlook 2000. The current project I am working on is an anti-spam system.

My goal is to check emails (Deleting the spam) whilst they are still on the server before normal retrieval by Outlook 2000. I have easily achieved most of this using various POP3 libraries but now want Outlook to download the remaining mails only when the server has been "cleaned".

How do I programmatically, through the Outlook object model, cause Outlook to check for new messages. Manually, one would do this by:
a) Pressing F5;
b) Pressing the Send/Receive button, OR;
c) Tools - Send/Receive - All Accounts

Obviously I would like my application to be running in the background (Or regularly scheduled), downloading the non-spam email at regular intervals - similar to the "Mail Delivery" option of check for new messages every X, however not being driven by Outlook but instead my external application.

I have found the CreateItem method but nothing comparable for retrieving mail.

Thanks for any help that can be offered,

Regards

Simon
 
Old July 17th, 2003, 08:49 AM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

http://www.freevbcode.com/ShowCode.Asp?ID=2139

 
Old July 17th, 2003, 02:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thanks to Riouxnick for this pointer. Rather than writing in VB, I am in fact using Visual FoxPro, so have found that the example text pointed to needed some modifications.

In case anyone is wondering, here is the solution that I found to work:
************************************************** ******
LOCAL loOutlook, loCommandBarCollection, loStandardCB
*
loOutlook = CREATEOBJECT("outlook.application")
*
= loOutlook.GetNameSpace("MAPI").GetDefaultFolder(6) .GetExplorer && Make sure that a mail folder (I have chosen the Inbox) is active, even if still hidden - as one can't Send/Receive from say a Notes folder
*
loCommandBarCollection = loOutlook.ActiveExplorer.CommandBars
FOR x = 1 TO loCommandBarCollection.Count
    IF PADR(UPPER(loCommandBarCollection.Item(x).Name), 10) = "STANDARD "
        loStandardCB = loCommandBarCollection.Item(x)
        EXIT
    ENDIF
ENDFOR
IF TYPE("loStandardCB") # "O" && Just incase the Standard toolbar can't be found
    RETURN .F.
ENDIF
= loStandardCB.Controls("Send/Receive").Execute
RETURN .T.
************************************************** ******





Similar Threads
Thread Thread Starter Forum Replies Last Post
E-mail using VBA and Outlook cc16 Access VBA 6 December 4th, 2006 11:07 AM
send/receive in MS Outlook dotnetprogrammer VS.NET 2002/2003 0 February 25th, 2005 12:01 AM
Receiving mail with Outlook 2000 VBA spotts-71 All Other Wrox Books 3 August 24th, 2004 10:41 AM
Outlook 2000, VBA, random signatures michaelrayadkins Beginning VB 6 1 June 4th, 2004 07:49 AM
Receiving mail with Outlook 2000 VBA spotts-71 Pro VB 6 7 July 17th, 2003 03:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.