We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Using MAPI to save mail in eml format

Hi Team,


We are in search of a new protocol to fetch the received Email and save it in .eml format,
Previously we were using IMAPClient and ExchangeClient where the former was removed as security concern and the later is working for only attachments lesser than 10MB,

The project is in x86 architecture since we do have a lot of dependent integrations on the same ,
So Can anybody please help me in using MAPI to fetch the mail and save it in .eml format and which would also handle attachments of size upto 30-40MB?

Regards,
B

Hi,


Thank you for contacting Aspose Support team.

Aspose.Email for .NET doesn’t have any implementation of MAPI to fetch emails from server and save these as EML. However, we have tested our EWS Client and couldn’t find any issue while fetching large emails having upto 30 MB attachments. The emails are fetched and saved properly to disc in EML format without having any issue. Could you please elaborate what sort of problem are you facing with our EWS Client while fetching large emails? Also, share with us the Exchange Server version you are using at your end.

Hi Kashif,


The Issue we’re facing is with the below code,

Aspose.Email.Exchange.IEWSClient MailEWSClient = Aspose.Email.Exchange.EWSClient.GetEWSClient(server, credentials);
Aspose.Email.Exchange.ExchangeMessageInfoCollection EWSMsgCollection = MailEWSClient.ListMessages(MailEWSClient.MailboxInfo.InboxUri);
try
{
foreach (Aspose.Email.Exchange.ExchangeMessageInfo msgInfo in EWSMsgCollection)
{
string msgFile = @“C:\Mails” + msgInfo.MessageId.ToString().Replace("<", “”).Replace(">", “”).Replace("@", “-”) + “.eml”;
MailEWSClient.SaveMessage(msgInfo.UniqueUri, msgFile);

So the highlighted is the place where we’re getting an “OutOfMemory Exception” , PFB for the same,
Error: System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.
at System.Text.StringBuilder.set_Length(Int32 value)
at System.Xml.XmlTextReaderImpl.ParseText()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at Aspose.Email.Exchange.Schema.Exchange_2013.ExchangeServiceBinding.GetReaderForMessage(SoapClientMessage message, Int32 bufferSize)
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at Aspose.Email.Exchange.Schema.Exchange_2013.ExchangeServiceBinding.GetItem(GetItemType GetItem1)
at #=qO5xM$NrpEzr8cFfF3zn0DBThQYDg3ZoqaIVtm7loSaV$hjRwSwp0xueZxnZPsWYU.FetchMessage(String #=qkcl3iCV_yW0_Rrwf6RphGg==)
at #=qO5xM$NrpEzr8cFfF3zn0DBThQYDg3ZoqaIVtm7loSaV$hjRwSwp0xueZxnZPsWYU.SaveMessage(String #=qkcl3iCV_yW0_Rrwf6RphGg==, Stream #=quXkfseFS2oxqBe4I7duDTA==)
at #=qO5xM$NrpEzr8cFfF3zn0DBThQYDg3ZoqaIVtm7loSaV$hjRwSwp0xueZxnZPsWYU.SaveMessage(String #=qkcl3iCV_yW0_Rrwf6RphGg==, String #=q2p_t6saySckKYHnMHKNt$w==)
at Email.ProcessInboundEmails()

This happens whenever the size of the attachment inside the mail is more than 10MB, the exchange server being used is Exchange 2013 and the code is built in x86 architecture,

Also I tried “MailEWSClient.FetchMessage” which is also causing the same issue,

Any help on this is really appreciated,

Regards,
B

Hi,


Thank you for sharing your feedback.

We have analyzed the Exception details and have come to conclusion that the bug is not related to Aspose.Email API but .NET framework when it comes to x-86 architecture. We are sorry but we won’t be able to fix this in our API for this reason. Please let us know if we can be of any additional help to you in this regard.

Ok thanks for the response,

But is there any other email protocol that can be leveraged using Aspose excluding IMAP and Exchange client, so the system will be able to handle higher attachment size in x86?

Regards,
B

Hi,


Aspose.Email API provides three main protocols for fetching messages from email servers.

1. Exchange Protocol (WebDav and EWS)
2. IMAP
3. POP3

You can try POP3 at your end to see if it meets your requirement as you can use it to connect to Exchange server and let us know if we could be of any additional help to you in this regard.