La bitácora de rodri

junio 15, 2011

macro archivado de mensajes en un pst

Archivado en: outlook — rodri @ 2:54 pm

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

Advertisement

Dejar un comentario »

Aún no hay comentarios.

RSS feed para los comentarios de esta entrada.

Deja un comentario

Please log in using one of these methods to post your comment:

Logo de WordPress.com

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

Twitter picture

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

Facebook photo

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

Connecting to %s

Tema Silver is the New Black. Blog de WordPress.com.

Seguir

Get every new post delivered to your Inbox.