I have a situation that is driving me nuts.
My outlook add-in is supposed to get the filename of the attachment of the open email before it is sent out (I trap this in the itemsend event)
Now, if I take any existing email in the inbox (with an attachment) and forward this email to xyz then the code (see code) works fine. However, when I create a new email, the value of attachment.filename (or .displayname) is the same as the previous email forwarded. The value not refreshed or reset.
Please help. See code
Dim myItem As Object = Nothing
Dim myAttachments As Object = Nothing
Dim myOrt As String = Nothing
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer = Nothing
Dim myOlSel As Outlook.Selection = Nothing
Dim explorer As Outlook.Explorer = Me.OutlookApp.ActiveExplorer
CancelSendMail = False
myOrt = "C:\temp\"
Dim currUser As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name
myOlSel = explorer.Selection
For Each myItem In myOlSel
myAttachments = myItem.Attachments
If myAttachments.Count > 0 Then
'for all attachments do...
For i = 1 To myAttachments.Count
'save them to destination
myAttachments(i).SaveAsFile(myOrt & _
Dim FileID As String = myOrt & _
'Dim FileID As String = myAttachments(i).DisplayName