Simeon
New Member
Hi together,
i have a VBA Macro which works excellent on my Main Outlook-Mailbox.
The Macro checks the subjects of the E-Mails and save the attachments on the Harddrive if it matches to a String to search for in the Code.
However, i need to use this Macro on a shared Outlook Mailbox. And here the trouble starts. I can't change the Macro to work on a other Inbox.
The Macro is only accessing my Main Inbox.
Where I can define the Mailbox i want to target?
Please see my Code below. For this example i'm looking for Mails with "Chandoo" in the Subject (for sure it can be everything else) .
Somebody can help please?
Thanks in advance.
Simeon
i have a VBA Macro which works excellent on my Main Outlook-Mailbox.
The Macro checks the subjects of the E-Mails and save the attachments on the Harddrive if it matches to a String to search for in the Code.
However, i need to use this Macro on a shared Outlook Mailbox. And here the trouble starts. I can't change the Macro to work on a other Inbox.
The Macro is only accessing my Main Inbox.
Where I can define the Mailbox i want to target?
Please see my Code below. For this example i'm looking for Mails with "Chandoo" in the Subject (for sure it can be everything else) .
Code:
Sub SaveMyAttachments()
Dim objOutApp As Outlook.Application
Dim objOutNameSpace As Namespace
Dim objOutMapi As MAPIFolder
Dim objOutMail As Variant
Dim lngz As Long
Dim lngCount As Long
Set objOutApp = New Outlook.Application
Set objOutNameSpace = objOutApp.GetNamespace("MAPI")
Set objOutMapi = objOutNameSpace.GetDefaultFolder(olFolderInbox)
For Each objOutMail In objOutMapi.Items
If objOutMail.Class = olMail Then
With objOutMail
lngCount = .Attachments.Count
If lngCount > 0 And objOutMail.Subject = "Chandoo" Then
For lngz = 1 To lngAnzahl
.Attachments.Item(lngz).SaveAsFile ThisWorkbook.Path & "\" & .Attachments.Item(lngz).Filename
Next lngz
End If
End With
End If
Next objOutMail
MsgBox "It's Done!"
Set objOutMapi = Nothing
Set objOutNameSpace = Nothing
Set objOutApp = Nothing
End Sub
Somebody can help please?
Thanks in advance.
Simeon
Last edited: