ImapMessageInfo.Date is offset

Hi,

I've written a little tool that uses Aspose.Email to parse a Gmail inbox and process all messages.

I noticed the Date property of the ImapMessageInfo is always off by 2 hours. When I open the mail header (see below) it shows "09:18:07 +0200", but when I run it through the tool, the Date comes as "07:18".

I understand this is related to the +0200. It's as if the ImapMessageInfo reverts the +02 to the original GMT-time?

Since the email could come from a different timezone, I can't just add 2 hours and be done with it. How can I access the exact date as it appears in the email header?

Kind regards,
Jeroen Vantroyen

The original header :
Delivered-To: cs@xxxxxxx.xx
Received: by 10.170.96.69 with SMTP id n66csp24748yka;
Fri, 12 Sep 2014 00:18:26 -0700 (PDT)
X-Received: by 10.50.117.6 with SMTP id ka6mr6395583igb.48.1410506305741;
Fri, 12 Sep 2014 00:18:25 -0700 (PDT)
Return-Path:
Received: from mail-ig0-f179.google.com (mail-ig0-f179.google.com [209.85.213.179])
by mx.google.com with ESMTPS id f18si3817749icg.50.2014.09.12.00.18.25
for
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Fri, 12 Sep 2014 00:18:25 -0700 (PDT)
Received-SPF: pass (google.com: domain of isabelle@xxxxxxx.xx designates 209.85.213.179 as permitted sender) client-ip=11.22.33.44;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of isabelle@xxxxxxx.xx designates 209.85.213.179 as permitted sender) smtp.mail=isabelle@xxxxxxx.xx
Received: by mail-ig0-f179.google.com with SMTP id r10so57057igi.0
for ; Fri, 12 Sep 2014 00:18:25 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20130820;
h=x-gm-message-state:from:references:in-reply-to:mime-version
:thread-index:date:message-id:subject:to:content-type;
bh=sLdcYSsDcXULmwNM57gBL+RAuZt09V2R73aN3iEGx/w=;
b=iArO8DlDzfhqczLhXw7eXPhuqssAc7mneu7PWtOwtmTyjDtQSbDgUnhx26WYBu1paM
K2NtVlNKtawE0sNZHBAhIdNkaZ3ONF5gi+mceVEYTdRXZK4vWtIQHL0JEKgdSkjOrCb1
GaCqMAfO0xnfPd+xK4BZXINp4pVK0ffJhLhkDetcR0DNw3aKhoLvDpUsjiVu+jbmFvLo
b1BTEthrt2eVfaMnL6PRA7UP919L6CRPMwnBZwJ1h4ty8y7LhCklUwzMc1Jj+f3HYeH4
sxl4uvDZF2+skfKgEpXtPymqYMuaRe6+mCfzjldMlEz/wZvkiXjVPaWYxd/WSuysKGdl
IJMg==
X-Gm-Message-State: ALoCoQkUIcxgRnKz2h9rdD8I3Gv+M6yfFIsBA7BjGsDd3fShhiZX94aIlHjDSK+oWOuVKhH6Vclq
X-Received: by 10.50.164.167 with SMTP id yr7mr14042115igb.37.1410506304745;
Fri, 12 Sep 2014 00:18:24 -0700 (PDT)
From: Isabelle
References: <16E11FA974B21544B6EE209FAC29688263684E@EXCHANGE2K10-1.province.luxembourg.net>
<43e9738a06ac4d1a461f68542e713a81@mail.gmail.com> <16E11FA974B21544B6EE209FAC2968826388E6@EXCHANGE2K10-2.province.luxembourg.net>
In-Reply-To: <16E11FA974B21544B6EE209FAC2968826388E6@EXCHANGE2K10-2.province.luxembourg.net>
MIME-Version: 1.0
X-Mailer: Microsoft Outlook 15.0
Thread-Index: AQDgGxhVcxLP30tqEqj8eHcfEIToOgE32eRgAjITWtSdwS3AwA==
Date: Fri, 12 Sep 2014 09:18:07 +0200
Message-ID:
Subject: =?UTF-8?Q?TR=3A_Balise_march=C3=A9_de_travaux=2E?=
To: CS@xxxxxxx.xx

Hi Jeroen,

Thank you for writing to Aspose support team.

The Date property of ImapMessageInfo shows the time in GMT and the Timezone offset is not available in the ImapMessageInfo. The TimeZone offset resides in the MailMessage’s TimeZoneOffset that is available once the message is fetched, which can then be used to determine the message time.

Code Used:


using (ImapClient imap = GetAsposeImapClient())

{

imap.SelectFolder(“INBOX”);


var infos = imap.ListMessages();


Console.WriteLine("Total Messages: " + infos.Count);


foreach (var info in infos)

{

Console.WriteLine(info.Date + ", " + info.InternalDate);

using (var message = imap.FetchMessage(info.UniqueId))

{

Console.WriteLine(message.Date + message.TimeZoneOffset);

}


break;

}


imap.Disconnect();

}

I didn’t need the actual message, so I didn’t look far enough for my date.

Thanks for the quick response!

Hi Jeroen,

I hope the shared solution is helpful to you. Please feel free to write to us if you have any further query/inquiry in this regard.