how can extract the attachement form .msg file. [Resolved]

Posted by Bageshkumarbagi under ASP.NET on 12/11/2013 | Points: 10 | Views : 4994 | Status : [Member] | Replies : 3
hi,

i have some file in .mgs extension. in that file have some pdf attachment. i want to extract the attachment. how can i do my job. plz give the solutation. its urgent.

Thanks in advance.

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied



Responses

Posted by: Bageshkumarbagi on: 12/19/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi,

I got the solutation
refer the link:- http://www.dotnetfunda.com/codes/show/5844/extracting-attachement-from-msg-file

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 12/11/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
You can use the below code to save you all attachment form .msg outlook mail file.

private static void main()
{
//create new Outlook message from file
OutlookStorage.Message outlookMsg = new OutlookStorage.Message(@"C:\test.msg");
}

private static void SaveMessage(OutlookStorage.Message outlookMsg)
{
outlookMsg.Save(outlookMsg.Subject.Replace(":", ""));

foreach (OutlookStorage.Attachment attach in outlookMsg.Attachments)
{
byte[] attachBytes = attach.Data;
FileStream attachStream = File.Create(attach.Filename);
attachStream.Write(attachBytes, 0, attachBytes.Length);
attachStream.Close();
}

foreach (OutlookStorage.Message subMessage in outlookMsg.Messages)
{
SaveMessage(subMessage);
}
}


See the below link:-
http://www.codeproject.com/Articles/32899/Reading-an-Outlook-MSG-File-in-C

Happy coding.
If this help to you, please click on Mark As Answer link.

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 12/11/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks for ur response @Allemahesh
But when i am using this code i am getting this error message
"The type or namespace name 'OutlookStorage' could not be found (are you missing a using directive or an assembly reference?)"

plz give some idea about it.

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

Bageshkumarbagi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response