Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8983291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:48:20+00:00 2026-06-15T20:48:20+00:00

The below code is working for CSV file but when we use the same

  • 0

The below code is working for CSV file but when we use the same code to read excel file it is returning different letters in the file

foreach (MimeAttachment attach in msg.Attachments)
{
if (attach.Filename != "")
{
//read data from attachment
string myString = attach.Body.Replace("=\r\n", ""); //to eliminate the '=\r\n' from email attachemnt
Byte[] b = GetBytes(myString);

// save attachment to disk
System.IO.MemoryStream mem = new System.IO.MemoryStream(b, false);
FileStream outStream = new FileStream(DownloadFilePath + "\\" + attach.Filename, FileMode.Create);
mem.WriteTo(outStream);
mem.Close();
outStream.Flush();
outStream.Close();
}
}

ex:

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAAiwAAAAAAAAAA
EAAAjQAAAAEAAAD+////AAAAAIgAAACMAAAA////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////8J
CBAAAAYFAGcyzQfJgAEABgYAAOEAAgCwBMEAAgAAAOIAAABcAHAACQAAYXNoYWFyIE0uICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:48:22+00:00Added an answer on June 15, 2026 at 8:48 pm

    This works for me

    foreach (OpenPop.Mime.MessagePart attachment in attachments)
                            {
                                if (attachment != null)
                                {
                                    string ext = attachment.FileName.Split('.')[1];
    
                                    Filename = DateTime.Now.Ticks.ToString();
                                    FileInfo file = new FileInfo((AppDomain.CurrentDomain.BaseDirectory + "Downloaded//") + Filename + ".csv" );
    
                                    // Check if the file already exists
                                    if (!file.Exists)
                                    {
                                        attachment.Save(file);
                                    }
    
                                }
                      }
    

    or try this

    How to save email attachments in C#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below code is working for list view, but i want to use listbox instead
Code below is working well as long as I have class ClassSameAssembly in same
The code below is working, but with a problem I do not understand. When
Below code is working properly now. But if I replace 'text.txt' with ' http://google.com
I've got the below code working, in KSH but it takes the jobs a
My below code is working fine when used in HTML. The same code I
The below code is working fine. But if i change the html string in
I know hashtable doesnt allow null keys ...but how is the below code working.
I have below code working as desired but the on select works only from
I got the below code from SO expert but it's working for ANSI Strings

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.