I'm trying to attach a file to all the mails in my Outbox folder using Outlook. I ran the following code:
Public Sub ABT()
Dim olNs As Outlook.NameSpace
Dim olOutbox As Outlook.MAPIFolder
Dim olItem As Object
Dim olEmail As Outlook.MailItem
Set olNs = GetNamespace("MAPI")
Set olOutbox = olNs.GetDefaultFolder(olFolderOutbox)
For Each olItem In olOutbox.Items
If olItem.Class = olMail Then
Set olEmail = olItem
With olEmail
.Attachments.Add "C:\Users\Augustin\Pictures\znakovi\blah.jpg"
.Save
.Send
End With
End If
Next
End Sub
But when I run the code, it tells me that I don't have the appropriate permissions to perform this operation.
I started Outlook in Administrator mode, so I think this error shouldn't happen and I would be very thankful if someone could point me to the solution.