How to replicate Headers("Date") from MailMessage to Office365Message

I’m trying to get the Headers(“date”) output equivalent in MailMessage to using Office365, specifically this format.

ddd, dd MMM yyyy H:mm:ss zzzz (UTC)

I’ve tried putting the Office365 mail to MailMessage but the Headers(“date”) is always blank.
I also tried using the Office365.ReceivedDateTime but it only outputs DateTime in "MM/dd/yyyy HH:mm:ss

Is there any office365 property to display the time format? It’s ok too if there is a way to convert Office365Message var to MailMessage var. correctly.

Hi @Shinjid ,
I want to know what is “ddd” , “zzz” ?
I think '“ddd” is day of week, right?

Yes that is right. It’s like this
Fri, 12 Nov 2021 21:51:15 +0800

Hi @Shinjid ,
You can use
DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(yourString,“\d+\s+[A-Za-z]{3}\s+\d{4}\s+\d{1,2}:\d{1,2}:\d{1,2}\s+[-+]?[\d:]+”).Value, “d MMM yyyy HH:mm:ss K”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

If the value returned is of datetime then you can use .ToString in the end and specify your format.

E.g:- dateVariable.ToString(“MM/dd/yyyy”)

If the value is a string variable you can use parse or parse exact.

E.g:- DateTime.ParseExact(StringVariable,“ddd, dd MMM yyyy H:mm:ss zzzz”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

It gives String was not recognized as a valid DateTime. Maybe because the ReceivedDateTime Property output is in MM/dd/yyyy HH:mm:ss only.

You can try


Custom what you want


Sorry I don’t get it. I’m trying to get the Received Date from an Email Var(Office365). What would I use the current date time with?

the Headers of mail is String, you can use string same my solution
Or, can you share your wrong code ?

Hi @Shinjid

Try this:

  1. Use the “Get Outlook Mail Messages” activity to retrieve the Office 365 messages.
  2. Use For each to iterate through messages, use the “Assign” activity to convert the date to the desired format.
    receivedDateTime = DateTime.ParseExact(currentItem.Headers(“Date”).ToString, “MM/dd/yyyy HH:mm:ss”, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal).ToString(“ddd, dd MMM yyyy H:mm:ss zzzz (UTC)”)

Hope it helps.

Sorry guys, I wasn’t searching well in the internet. Using .Headers(“date”) works just the same. I just had to update the version from 1.14.1 and newer(i was using 1.11.1)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.