i’m migrating an old application, from the “very old” Aspose.Network…
there are a lot of deprecated and renamed members… anyway, i have a couple of problems/conflicts i’m not able to solve by myself:
- Aspose.Email.Pop3.Pop3Authentication [Auto, ClearText, CramMD5, DigestMD5, Login, Plain]
Can’t find that anymore… ?
- Aspose.Email.Mail.Attachment - property “ContentType” was a string. How should i convert it? should i replace it with “ContentType.MediaType” ?
- Aspose.Email.Mail.LinkedResource - lost properties: “Name” and “MediaType”
- Aspose.Email.Pop3.Pop3Client - i see that “Connect” and “Login” methods are deprecated.
i suppose now it is an “auto-connect”… how can i just test the connection (to check credentials/security) ?
Thank you for contacting Aspose Support team.
The ClearText, CramMD5 etc. are no more available and you may use the simplest form of the Pop3Cleint to initialize it. Unfortunately support of CramMD5, DigestMD5, never been implemented. There were only plans for theirs implementation. Enumeration, where these types of authentication have been mentioned, were never used. That’s why this enumeration is removed.
You may use the ContentType.MediaType to get information about the media type of the attachment.
Please use the LinkedResource.ContentType.Name and ContentType.MediaType to get this information.
Yes, the API accesses the server on its first attempt to retrieve any data and Connect/Login methods are obsolete now. You can do a simple quick test for getting Mailbox information using the following code to determine the correctness of the credentials. It will raise exception if the credentials are not correct.
// Create a pop3client Aspose.Email.Pop3.Pop3Client pop = new Aspose.Email.Pop3.Pop3Client(“[mail.domain.com](http://mail.domain.com/)”, “username”, “password”); // Get the size of the mailbox long nSize = pop.GetMailboxSize(); Console.WriteLine(“Mailbox size is " + nSize + " bytes.”);
thank you for the prompt reply…
i didn’t understand what do you mean with:
1. […] you may use the simplest form of the Pop3Cleint to initialize it. […]
Following is the sample code to initiate Pop3Client.
Pop3Client client = new Pop3Client(“[pop.gmail.com](http://pop.gmail.com/)”, 995, “userName”, “password”);<o:p></o:p> client.SecurityOptions = SecurityOptions.Auto;
Please have a look at the articles on the following link for more information about Pop3:
i run into another issue, about dates/time and timezones
with the old aspose.network mail message, i used to deal with "message.Date"
if i get it, it’s always in the correct timezone… if i set it with “DateTime.Now” it’s always set correctly.
Now, i’ve noticed that on the “new” Aspose.Email mail message, the property “Date” is not localized with the timezone, no more… so, how should i deal with getting/setting this property?
I’ve seen there is a “TimeZoneOffset” poperty… how should i use it? i think i have to migrate my code…
You can get the message date in UTC by adjusting the Time zone offset information as shown in the following code sample. Please try it at your end and share your feedback with us.
MailMessage eml = MailMessage.Load(“Sample.eml”);
Console.WriteLine(eml.Date + eml.TimeZoneOffset);
ok, so i have to replace my code, everywhere i read the message.Date, and add the timespan…
when i create a new message, i set the date with "message.Date = DateTime.Now"
should i change it?
should i set the zone timespan?
i understand the way to read it and show the local time to the client…
If i want to explicitly set the time of an outgoing message, how should i set it?
What is the “right” way?
And if i need to clone a message?
i know that mail servers add times and other stuffs to headers etc.
anyway, the “message datetime” is set by client. In fact, if you send emails from a mail client (thunderbird) from a PC with an incorrect datetime settings, when someone receives that message, the datetime of the message is incoerent.
With your component, is the same. If i set explicitly the message date, the email client receiving the email, shows the date set by ME… the servers on the way, just append some other dates. But the one showed, is the one set by my code.
In my case, i have an application developed with the “old” aspose.network library.
When the application sends the message, there is this code:
asposeMessage.Date = DateTime.Now;
Now, i changed the dll with the aspose.email, and i left the same code, and i compare the “old” messages, with the messages sent with the new DLL.
They have been sent with the same sender, same smtp server, same application.
If i open the messages with an email client, they both show the same date.
But if look at the “source” of the email, there is a difference:
This is sent with aspose.network:
This is sent with aspose.email:Date: Tue, 9 Feb 2016 13:02:25 +0100
It’s the same time, but the correct is the first.Date: 9 Feb 2016 12:02:25 +0000
Now, i suppose i have to set the date with:
DateTime dataOra = DateTime.Now;Is it correct?
asposeMessage.Date = dataOra;
asposeMessage.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(dataOra);
so, why the date header is different between the messages sent with aspose.network and aspose.email?
the newer is uncorrect.
Anyway, i’ve tested it right now… i can confirm you that, if i set an “incorrect” datetime to an aspose MailMessage Date property, i receive the email and my mailclient show it with that time. (incorrect)
Examining the message source, there are other headers with a date (added by the mail servers) but the date shown by the mail client is the one i set when i sent the message, with
message.Date = wrongDate;
How can i send you the message?
here is the message sent in year “2020”
- System timezone
- System date and time
- MailMessage.Date value
- Mail server (I used Gmail for sending and receiving)
- Thunderbird version to use
sorry, i didn’t want to set the whole thread as private, just wanted to mark as private the post with the attachament.
anyway, i tested with the 6.2.0 and had the same behaviour… the date i see on the receiving client, is the date i set at code.
If I use gmail, instead, that date is overwritten with the correct “now”.
So, it’s a matter of SMTP server… i think the SMTP server of our ISP provider, doesn’t overwrite the date header, keeping the date provided by Aspose, while gmail rewrites it.
So, i suppose i have to edit my code to set the Aspose date/timezone properly.
is this code ok?
DateTime serverNow = DateTime.Now;
asposeMessage.Date = serverNow.ToUniversalTime();
asposeMessage.TimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(serverNow);
And, about the reading messages from the pop3 server, i read the mail infos, with
myPopClient.ListMessages()but the “Pop3MessageInfo” class, doesn’t have a property with UTC offset… how can i get it?
thank you for support!
ok, thank you!