We have a small macro (added to the ribbon) which on click is supposed to attach some files from a certain folder.
This works, when creating a "new" Mail from within Outlook. When you use (for example) Adobe Acrobats "send as email" Function, the email in Outlook is opened as modal dialog.
The button on the ribbon now has no effect. It simple does nothing. (Not even a MessageBox in the first line would be displayed) Using Developer Tools -> Macros and selecting the macro from "there" works.
Why isn't the button on the ribbon, calling the very same macro NOT working with modal emails?
the macro - but as mentioned not even a MessageBox would appear.
Sub AddAttachments()
Dim Path As String
Path = "C:\test\"
Dim NewMail As MailItem, oInspector As Inspector
Set oInspector = Application.ActiveInspector
If oInspector Is Nothing Then
MsgBox "No active inspector"
Else
Set NewMail = oInspector.CurrentItem
If NewMail.Sent Then
MsgBox "This is not an editable email"
Else
With NewMail
d = Dir(Path & "*.*")
While d <> ""
.Attachments.Add Path & d
d = Dir
Wend
End With
End If
End If
End Sub
Update: With another application offering more settings for the email-sending application, I was able to figure the following out:
- When using "Outlook OLE" als Email-Sending Method, everything works as expected.
- When using "MAPI" as Email-Sending Method, the effect mentioned above appears.
So, Adobe Acrobat seems to use (Simple) MAPI by default.
Edit: After knowing the actual cause, I found this: https://www.msoutlook.info/question/203 - Seems to be a known, not solvable limitation for Applications creating their emails through MAPI because Outlook is not loaded "fully" but just some basic stub.
Update:
When clicking on the "Send as mail Button" (1) the following Window appears. Clicking on the "Macro-Button" inside the ribbon (2) does nothing.
Switching to DeveloperTools, Selecting "Macros" and selecting the same Macro from there however works:
The Button on the other hand works for "New Emails" created via Outlook and "New Mails" created by using Outlook OLE
rathen than MAPI
.
Sub AddAttachments()
, see if that helps, can you also post an image ofOutlook modal dialog
when you use Adobe ? – 0m3r