Cannot save the attachment. Outlook cannot perform this action on this type of attachment.

Add-in Express™ Support Service
That's what is more important than anything else

Cannot save the attachment. Outlook cannot perform this action on this type of attachment.
 
wehbi




Posts: 76
Joined: 2013-10-31
Dear ADX Team,

what I'm doing is to intercept the attachment add event and save the attachment to the local file system.
I was using this approach for a while now, but it seems not to working anymore.
The wired thing is, it is working with ZIP files but not with e.g. PDF or TXT files.


public override void ProcessBeforeAttachmentAdd(object attachment, ADXCancelEventArgs e)
{
    if (!(attachment is Outlook.Attachment olAttachment)) return;
    olAttachment.SaveAsFile(@"C:	emp	emp.pdf");
    Marshal.ReleaseComObject(olAttachment);
}


The code above will throw the following exception:


Exception Source:      Microsoft Outlook
Exception Type:        System.Runtime.InteropServices.COMException
Exception Message:     Cannot save the attachment. Outlook cannot perform this action on this type of attachment.
Exception Target Site: SaveAsFile

---- Stack Trace ----
   Microsoft.Office.Interop.Outlook.Attachment.SaveAsFile(Path As String)
       com.befine_solutions.cs4outlook.DLL: N 00000 (0x0) JIT 
   com.befine_solutions.cs4outlook.OutlookItemEventsClass.ProcessBeforeAttachmentAdd(attachment As Object, e As ADXCancelEventArgs)
       OutlookItemEventsClass.cs: line 0181, col 04, IL 0018 (0x12)
   AddinExpress.MSO.ADXOlItemEvents_10_SinkHelper.AddinExpress.MSO.IOutlookItemEvents_10.BeforeAttachmentAdd(attachment As Object, cancel As Boolean&)
       com.befine_solutions.cs4outlook.DLL: N 0006 (0x6) IL 


As soon as I give a delay to the execution by a timer, the SaveAsFile procedure can be triggered without causing an exception.

Regards,
Birger
Posted 11 Feb, 2020 03:49:36 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Birger,

If you see this issue with *all* other add-ins turned off, your only option is to delay the save.


Andrei Smolin
Add-in Express Team Leader
Posted 11 Feb, 2020 04:48:56 Top