We have created an outlook add in so that a user can press a button in Outlook and add a pdf file as an attachment automatically, to save them time having to try find it on the system
Tried different ways of using mailItem.Attachments.Add but they all seem to have the same problem
Private Sub OfficeAccount_Click(sender As Object, e As RibbonControlEventArgs) Handles OfficeAccount.Click
Dim theAttachment = "http://webapps/Intranet/Home/Office/Documents/Template.pdf"
Dim item = TryCast(Me.Context, Outlook.Inspector)
Dim mailItem = TryCast(item.CurrentItem, Outlook.MailItem)
mailItem.Attachments.Add(theAttachment, , , "Template")
Marshal.ReleaseComObject(mailItem)
End Sub
It usually adds the attachment but sometimes it stops adding the attachment and says index out of bounds.
It then also stops allowing attachments to be added normally and has the same error message