开发者

pop3 mail client(openpop.net) failed to get a mail which has been scanned by SurfControl plc

I am using pop3 client(openpop.net) to get a mail from a pop3 server. It works fine for a开发者_如何学运维ll mails till now. But now it failed to get a mail using the GetMessage(index) method. The message object obtained from the above method is null for the particular mail.

I checked the mail manually and when i opened it i found the following message inside it:

This message has been scanned for malware by SurfControl plc. www.surfcontrol.com

The c#.net code is as follows:

using (Pop3Client client = new Pop3Client())
{
    client.Connect(HostName, Port, UseSsl);
    client.Authenticate(UserName, Password);

    int MessageCount = client.GetMessageCount();

    MessageHeader h= client.GetMessageHeaders(MessageCount);

    List<int> deleteIndexes = new List<int>();

    #region Process all mails

    for (int index = 1; index <= MessageCount; index++)
    {
        try
        {
            #region Process the downloaded mail

            Message message;

            try
            {
                message = client.GetMessage(index);
            }
            catch
            {

            }

            MessageHeader Headers = message.Headers;

            RfcMailAddress FromMail = Headers.From;
            string Subject = Headers.Subject;
            string From = FromMail.Address;
            string ReceivedDate = Headers.DateSent.ToLocalTime().ToString();
        }
    }
}

Why did i am not able to get this mail using the mentioned function of pop3 client? Any one please help me to sort out this issue..

Stack Trace:

at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s, IFormatProvider provider) at OpenPop.Mime.Header.HeaderFieldParser.ParseContentDisposition(String headerValue) at OpenPop.Mime.Header.MessageHeader.ParseHeader(String headerName, String headerValue) at OpenPop.Mime.Header.MessageHeader.ParseHeaders(NameValueCollection headers) at OpenPop.Mime.Header.MessageHeader..ctor(NameValueCollection headers)

at OpenPop.Mime.Header.HeaderExtractor.ExtractHeadersAndBody(Byte[] fullRawMessage, MessageHeader& headers, Byte[]& body) at OpenPop.Mime.MessagePart.GetMessagePart(Byte[] rawMessageContent)

at OpenPop.Mime.MessagePart.ParseMultiPartBody(Byte[] rawBody) at OpenPop.Mime.MessagePart.ParseBody(Byte[] rawBody) at OpenPop.Mime.MessagePart..ctor(Byte[] rawBody, MessageHeader headers) at OpenPop.Mime.Message..ctor(Byte[] rawMessageContent, Boolean parseBody) at OpenPop.Mime.Message..ctor(Byte[] rawMessageContent) at OpenPop.Pop3.Pop3Client.GetMessage(Int32 messageNumber)


OpenPop.NET states that the best way to get support is to contact them on their mailing list:
hpop-users@lists.sourceforge.net

Are any exceptions being thrown by GetMessage(index)? It is not be possible for GetMessage(index) to return a null reference - but if it throws an exception your catch clause will do nothing and you will continue like nothing happened, and the message variable will not be set. Could you tell us if any exceptions are raised and give us the stack-trace if so?

Also, if you have not removed any code before posting this question, your code looks like a mess. Why are you fetching headers for the last message in the mailbox with the line:

MessageHeader h= client.GetMessageHeaders(MessageCount);

It does not seem that you are using it.

Also, it looks like in your for-loop, that you are fetching an email, only to look at the headers - then you should use the GetMessageHeaders(index) method to save bandwidth.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜