The IMAP shared folder from email "abc@domain.ru" is connected to my Outlook imap account. And sometimes i need move there email from my IMAP account. I'd like to create a macro that I can move selected emails in this IMAP shared folder.
P.S. Folder Need, Its not subfolder!
Make for this macro button and every time ERROR "This folder doesn't exist!".
P.S. Folder Need, Its not subfolder!
Code:
Example script:
[/FONT][/COLOR][COLOR=#333333]Sub need()[/COLOR]
[COLOR=#333333]On Error Resume Next[/COLOR]
[COLOR=#333333]Dim oApp As Outlook.Application[/COLOR]
[COLOR=#333333]Dim objFolder As Outlook.MAPIFolder[/COLOR]
[COLOR=#333333]Set oApp = New Outlook.Application[/COLOR]
[COLOR=#333333]Set objFolder = oApp.GetNamespace("MAPI").Folders("NEED")[/COLOR]
[COLOR=#333333]Dim oEmail As Outlook.MailItem[/COLOR]
[COLOR=#333333]'Assume this is a mail folder[/COLOR]
[COLOR=#333333]If objFolder Is Nothing Then[/COLOR]
[COLOR=#333333]MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]If Application.ActiveExplorer.Selection.Count = 0 Then[/COLOR]
[COLOR=#333333]'Require that this procedure be called only when a message is selected[/COLOR]
[COLOR=#333333]Exit Sub[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]For Each objItem In Application.ActiveExplorer.Selection[/COLOR]
[COLOR=#333333]If objFolder.DefaultItemType = olMailItem Then[/COLOR]
[COLOR=#333333]If objItem.Class = olMail Then[/COLOR]
[COLOR=#333333]objItem.Move objFolder[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]End If[/COLOR]
[COLOR=#333333]Next[/COLOR]
[COLOR=#333333]Set objItem = Nothing[/COLOR]
[COLOR=#333333]Set objFolder = Nothing[/COLOR]
[COLOR=#333333]Set objInbox = Nothing[/COLOR]
[COLOR=#333333]Set objNS = Nothing[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
Make for this macro button and every time ERROR "This folder doesn't exist!".