Copy sent emails to IMAP folder

G

Guest

I am after code that moves a copy of sent emails to an IMAP
folder named "Sent".

I have it set up presently as a rule but am wanting to do it in VBA.

Thanks in advance,

Brian
 
G

Guest

Thanks Michael,

Forgetting about the IMAP folder for one minute. I think the code is;
--------------------------------------------------------------------------
Private Sub olSentItems_ItemAdd(ByVal Item As Object)
Item.Move
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
End Sub
--------------------------------------------------------------------------
I put this in the VB editor in module 1, but nothing seems to happen and
it is not listed in the Macros list. I have turned off Macro security.

Any more suggestions please.

Cheers
 
M

Michael Bauer

Am Thu, 1 Dec 2005 05:42:03 -0800 schrieb Brian:

Events can be received in class modules only, e.g. in "ThisOutlookSession".
Additionally you need to subscribe to the event, example:

Private WithEvents olSentItems as Outlook.Items

Private Sub Application_Startup()
Set olSentItems = [whataver folder´s items you want to watch]
End Sub
 
M

Michael Bauer

Am Fri, 2 Dec 2005 11:21:12 +0100 schrieb Brian Tetlow:

Sorry, my fault. Instead of SentItems´ ItemAdd just use the
Application_ItemSend.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim oMail As outlook.MailItem

If TypeOf Item Is outlook.MailItem Then
Set oMail = Item
Set oMail = oMail.Copy
oMail.Move GetFolder("HereYourTargetFolder")
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top