Newbie request

  • Thread starter Thread starter fisherofsouls
  • Start date Start date
F

fisherofsouls

Could anyone help with a simple Outlook VBA programming request ?

Having signed up with Gmail, I would like to forward about 100 items
from an Outlook 2003 PST file to my Gmail account so that I can file
them. It strikes me that the simplest way to do this would be to
forward each one to my Gmail account. So I would like a code snippet
which achieves the following:

(1) Enumerates the messages in folder "Copy Of Inbox"
(2) For each message, forwards to "<my account>@gmail.com"
(3) Deletes each message

Could anyone oblige ?

Thanks and regards

Nick
 
Am 31 Jul 2005 10:58:18 -0700 schrieb (e-mail address removed):

Hi Nick,

do you like to write the code yourself? It´s really easy and perhaps the
only way to reach your aim...
 
Michael,

Well, I would (being fairly experienced with Excel VBA), but I posted
the request for the following reasons:

(1) I'm not familiar with the Outlook API
(2) I don't really have the time to learn it, much as I would love to
(3) It's just a simple task I want to automate and I probably will
never write another line of Outlook VBA code in my life

So if you or anyone could point me to a suitable snipped, _that_ would
be helpful.

Nick
 
On 1 Aug 2005 13:08:05 -0700 (e-mail address removed) wrote:

Fine, if you´re familiar with Excel VBA then you´re almost ready.

First you need a reference on the folder, you can use Sue´s function:
http://www.outlookcode.com/d/code/getfolder.htm

Then loop backwards through the folder´s Items collection with:

Dim i as Long
Dim oFolder as Outlook.MapiFolder
Dim obj as Object
Dim oMail as Outlook.MailItem

Set oFolder=GetFolder(...)

For i=oFolder.Items.Count To 1 Step-1
Set obj=oFolder.Items(i)
If TypeOf obj is Outlook.MailItem
Set oMail=obj
' oMail.Forward here
oMail.Delete
Endif
Next

Now you just have to complete the Forward line. Please read in the VBA help
how to use the function.
 
Back
Top