macro archivado de mensajes en un pst

El siguiente código permite  mover los mensajes de nuestra bandeja de entrada a una carpeta de nombre  “inbox” en un  fichero local pst de nombre ” archivado”.

————————————————————————————–

Sub archivado()
‘ Mover mensajes seleccionados a la carpeta “inbox” en “Personal Folder”
‘ alt+1

On Error Resume Next

Dim oApp As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Set oApp = New Outlook.Application
Set objFolder = oApp.GetNamespace(“MAPI”).Folders(“archivado”).Folders(“inbox”)
Dim oEmail As Outlook.MailItem

‘Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox “Esta carpeta no existe !!!!”, 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

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s