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

Free Support Forum - aspose.com

Unread Emails using IMAP

1) How can I get unread emails using IMAP

2)how can I manually set the email status to read/unread.

3) How do I forward a email with all the content.

Please help me with this............I'm working on POC for Aspose Network. FYI I use C#

Thanks

Prashant


Please answer my question if this is possible with aspose or not. I have a presentation in 2 hours.
I need to provide proof of concept on aspose network.

Hi Prashant,


Sorry for not replying earlier.

1) For getting un-read messages, you may call the ImapClient.ListMessages() to first get all the messages in a folder. Then you may check from each message’s properties in a condition, if it is read/un-read. For documentation, please refer to http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/fetch-messages-from-imap-server-and-save-to-disk.html.

You may also use the following code snippet:

ImapClient client = null;
client = new ImapClient(“host”, 143, “user”, “pwd”);
client.Connect(true);
client.SelectFolder(“Inbox”);
ImapMessageInfoCollection msgInfoColl = client.ListMessages();
foreach (ImapMessageInfo msgInfo in msgInfoColl)
{
Console.WriteLine(“Subject: " + msgInfo.Subject);
Console.WriteLine(“Read?: " + msgInfo.IsRead);
string fileName = msgInfo.Subject.Replace(”:”, " “).Replace(”?", " ");
// save as msg using MailMessage class
MailMessage msg = client.FetchMessage(msgInfo.SequenceNumber);
msg.Save(fileName + “.msg”, MailMessageSaveType.OutlookMessageFormat);
}

2) For changing status to read/un-read, you may change the message flags using ImapClient.ChangeMessageFlags() method. Sample code and details are available at http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/changing-the-message-flags.html.

3) For forwarding an email with all the content, you may first get the complete message using ImapClient.FetchMessage() method. Then call SmtpClient.Send() method. The code below may be added to the above example :
SmtpClient smtpClient = new SmtpClient("host", 25, "user", "pwd");
smtpClient.Send(msg);

Hey saqib ,

Thanks for ur reply but “msgInfo.IsRead” is always false. It doesn’t matter if its a new message or old message.

Regards
Prashant

Hi Prashant,


This is a bug and known issue in this version, which will be fixed soon.