Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

Commented Unassigned: Unable to get attachment filename [21972]

$
0
0
Hi All,

I encountered an exception while trying to get attachment filenames for an email in Outlook 2013 and wondering if anybody encountered this before?

The exception shows:
at NetOffice.Invoker.PropertyGet(COMObject comObject, ...)
at NetOffice.OutlookApi.Attachment.get_Filename()

This problem only happen with specific emails and not all.
And it seems to be email in RichText format with embedded attachments.
I tried to simulate this problem but did not encounter any problem on my own machine.

Anybody else ever encounter this problem?

The code snippet is as follow:

Outlook.Attachments olAttachments = _MailItem.Attachments;
int iTotalAtts = 0;
string AttachmentFolder = string.Empty;
if (olAttachments != null)
{
iTotalAtts = olAttachments.Count;
if (iTotalAtts > 0)
{
AttachmentFolder = _slMailObj.tmp_folder + Path.DirectorySeparatorChar + _slMailObj.mail_id + Path.DirectorySeparatorChar;
Directory.CreateDirectory(AttachmentFolder);
}

int nCount = 1;
foreach (Outlook.Attachment att in olAttachments)
{
string tmpAttachFile = AttachmentFolder + nCount.ToString("000") + "_" + att.FileName;
tmpAttachFile = wsFile.GetUniqueFileName(tmpAttachFile);
att.SaveAsFile(tmpAttachFile);
nCount++;
}
}

Thanks.
Comments: ** Comment from web user: long1000 **

Anybody has any idea?

Fyi, if I fwd this email to another user and then, try the same code, it works.
So this probably point to some formatting problem since once forwarded something in the email changed.


Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>