Wrox Programmer Forums
|
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books 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
  #1 (permalink)  
Old July 4th, 2003, 10:42 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Receiving mail with Outlook 2000 VBA

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
  #2 (permalink)  
Old July 17th, 2003, 03:06 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have just been pointed to http://www.freevbcode.com/ShowCode.Asp?ID=2139

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.
************************************************** ******
  #3 (permalink)  
Old August 23rd, 2004, 07:34 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

Here is the code from another source to invoke Outlook thru VFP:

#INCLUDE "MSOutl9.H"
LOCAL loOutlook as Outlook.Application, ;
loNameSpace as Outlook.NameSpace, ;
loFolder as Outlook.MAPIFolder, ;
loMailItem as Outlook.MailItem
loOutlook = CREATEOBJECT("Outlook.Application")
loNamespace = loOutlook.GetNamespace("MAPI")
loFolder= loNamespace.GetDefaultFolder(olFolderInbox)
loMailItem = loFolder.Items.Add(olMailItem)
WITH loMailItem
.To = "[email protected]"
.Attachments.Add(HOME()+"Fox.bmp")
.Display()
ENDWITH

  #4 (permalink)  
Old August 24th, 2004, 10:41 AM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

gokul_blr

My original question was how RECEIVE new mail. Your posting appears to be how to CREATE and SEND a new mail.





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
Outlook 2000, VBA, random signatures michaelrayadkins Beginning VB 6 1 June 4th, 2004 07:49 AM
receiving mails from outlook using webapplication spvarapu .NET Web Services 2 January 26th, 2004 09:42 AM
Receiving mail with Outlook 2000 VBA spotts-71 Pro VB 6 7 July 17th, 2003 03:04 PM
Outlook 2000 VBA - Receive mail... spotts-71 VB How-To 2 July 17th, 2003 02:56 PM





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