---
title: "Identify filename of Email Attachment"  
description: "Identify filename of Email Attachment"  
author: "Anonymous User"  
published: 2013-12-18  
updated: 2013-12-18  
canonical: https://www.mindstick.com/forum/1807/identify-filename-of-email-attachment  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Identify filename of Email Attachment

How do I get [filename](https://www.mindstick.com/interview/23463/difference-between-include-filename-and-include-filename) of the [email](https://www.mindstick.com/articles/12870/10-easy-ways-to-manage-your-business-email-inbox) attachment. I am using ActiveUp.Net.Mail.

```
Mailbox inbox = imap.SelectMailbox("inbox");int[] ids = inbox.Search("ALL");ArrayList mailContainer = new ArrayList();for (int x = 0; x < ids.Length; x++ ){   mailContainer.Add(inbox.Fetch.MessageObject(ids[x]));}foreach (Message msg in mailContainer){    if (msg.Attachments.Count > 0)    {        msg.Attachments.StoreToFolder(@path);    }}
```

I was [thinking](https://www.mindstick.com/blog/11889/how-to-change-your-thinking-paradigm) of [saving](https://www.mindstick.com/blog/11865/guide-to-saving-15-for-retirement) the attachment and then read the attachment...Is there a way I would directly read the attachment without saving if it in .xls [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format)?

## Replies

### Reply by Anonymous User

Hi Ankita,\

Looks like this should work...

```
foreach(var attachment in msg.Attachments){   attachment.StoreToFile(filepath + attachment.Filename);}
```


---

Original Source: https://www.mindstick.com/forum/1807/identify-filename-of-email-attachment

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
