exchangefreaks.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VBS to move mail from Exchange Mailbox's Inbox to a Public F

 
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Applications
Author Message
AlexCottrill



Joined: 31 Oct 2007
Posts: 1

PostPosted: Wed Oct 31, 2007 5:39 pm    Post subject: VBS to move mail from Exchange Mailbox's Inbox to a Public F Reply with quote

I would like VB scripts to move and copy an email received in any
user's Inbox to a specific sub-folder of the Public Folders, ie:

Mailbox - Bob Jones>Inbox -- move to --> Public Folders>Public
Folders>GFI Antispam Folders>This is spam email

The closest I've come to a script that works is the following, which
moves mail from the Inbox to a sub-folder of the Inbox (in this
instance Keep).

==START==
Sub MoveSelectedMessagesToFolder()

On Error Resume Next





Dim objFolder As Outlook.MAPIFolder, objInbox As
Outlook.MAPIFolder

Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem





Set objNS = Application.GetNamespace("MAPI")

Set objInbox = objNS.GetDefaultFolder(olFolderInbox)

Set objFolder = objInbox.Folders("Keep")











'Assume this is a mail folder


If objFolder Is Nothing Then

MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"

End If





If Application.ActiveExplorer.Selection.Count = 0 Then

'Require that this procedure be called only when a message is
selected

Exit Sub

End If





For Each objItem In Application.ActiveExplorer.Selection

If objFolder.DefaultItemType = olMailItem Then

If objItem.Class = olMail Then

objItem.Move objFolder

End If

End If

Next








Set objItem = Nothing

Set objFolder = Nothing

Set objInbox = Nothing

Set objNS = Nothing

End Sub

==END==

Archived from group: microsoft>public>exchange>applications
Back to top
View user's profile Send private message
Don Tweedie



Joined: 02 Jan 2008
Posts: 1

PostPosted: Wed Jan 02, 2008 11:41 am    Post subject: RE: VBS to move mail from Exchange Mailbox's Inbox to a Publ Reply with quote

Hi,

I am currently working on a project to move vaulted stubs from a public
folder to a mailbox. The catch is that I need to create the same folder name
prior to move.
Since this is the first time I have done a scripted move, I am looking for
any advice or assistance I can get with this.

We're you able to get this to work?

thanks in advance for your time.

Don

"AlexCottrill@googlemail.com" wrote:

> I would like VB scripts to move and copy an email received in any
> user's Inbox to a specific sub-folder of the Public Folders, ie:
>
> Mailbox - Bob Jones>Inbox -- move to --> Public Folders>Public
> Folders>GFI Antispam Folders>This is spam email
>
> The closest I've come to a script that works is the following, which
> moves mail from the Inbox to a sub-folder of the Inbox (in this
> instance Keep).
>
> ==START==
> Sub MoveSelectedMessagesToFolder()
>
> On Error Resume Next
>
>
>
>
>
> Dim objFolder As Outlook.MAPIFolder, objInbox As
> Outlook.MAPIFolder
>
> Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
>
>
>
>
>
> Set objNS = Application.GetNamespace("MAPI")
>
> Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
>
> Set objFolder = objInbox.Folders("Keep")
>
>
>
>
>
>
>
>
>
>
>
> 'Assume this is a mail folder
>
>
> If objFolder Is Nothing Then
>
> MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
> "INVALID FOLDER"
>
> End If
>
>
>
>
>
> If Application.ActiveExplorer.Selection.Count = 0 Then
>
> 'Require that this procedure be called only when a message is
> selected
>
> Exit Sub
>
> End If
>
>
>
>
>
> For Each objItem In Application.ActiveExplorer.Selection
>
> If objFolder.DefaultItemType = olMailItem Then
>
> If objItem.Class = olMail Then
>
> objItem.Move objFolder
>
> End If
>
> End If
>
> Next
>
>
>
>
>
>
>
>
> Set objItem = Nothing
>
> Set objFolder = Nothing
>
> Set objInbox = Nothing
>
> Set objNS = Nothing
>
> End Sub
>
> ==END==
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Problem with OWA accessing Inbox Hi All! quick question re/OWA with following configuration on client PC: Windows XP-Prof, all current patches installed IE acces to server via POP3 no proxy installed correct country settings in IE problem: mails are not displayed in i

huge amounts of 'Not read:' receipts arrivein my inbox Using Outlook XP 2002 with message tracking options set to notify me of emails i've sent that are read. Yesturday had several hundred emails with the subject: "Not read: Subject" & body of the email "your message to: fist lastname subject: ........ sent:

Move messages between mailboxes Hi, I need to write a service that works against a mailbox, moving all messages from there into different mailboxes based on the sender. Can somebody give me some pointers or point me to some code on how this can be done? I tried using C

Outlook 2003 calendar it may have been move On Vista with Office 2003 I have a users that keeps getting this on all invites for the calendar this meeting is not in the calendar it may have been moved or deleted I have already deleted the frmcache.dat file Please help

CDO Access Denied to Mailbox after move to 2007 Server We have an Application running on a SQL Server that opens up users mailboxes and adds appointments to their calendars. It works great and has been for years. We are in the process of migration to Exchange 2007. We moves some mailboxes over to the 2007
Post new topic   Reply to topic    exchangefreaks.com Forum Index -> MS Exchange Applications All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group