Rename file to email header date

Does anyone know how I can pick up a date from the email header and convert it into a date format?
The email header is as follows: “Daily Email - 22 Mar 2021”
I want to rename my file as “File_MMddyyyy” / “File_03222021”

The date is also in the file itself, but the format is “Name_22Mar2021”, but I need it in “File_0322021”

Thanks!

@JohnBoy - are you going to try this in Studio or StudioX?

Studio

Hi @JohnBoy …Thanks for the confirmation …but your requirement is little confusing …

So you have to extract the date from the email header or from the file name ?

@JohnBoy - You can try like this…

  1. StrDate = “Daily Email - 22 Mar 2021”.Split("-"c)(1).Trim
  2. CDate(StrDate).ToString(“MMddyyyy”)

This will give you 0322201 which you can use it for the filename…

OR

If you like to achieve it in one shot…you can try like this…

CDate(“Daily Email - 22 Mar 2021”.Split("-"c)(1).Trim).ToString(“MMddyyyy”)

Here you can replace “Daily Email - 22 Mar 2021” with your Email.header …

Hope this helps…

@JohnBoy - Did you get a chance to try this??

I decided to use a substring on the file name and then used your CDate(StrDate).ToString(“MMddyyyy”) to get it to the string format :slight_smile: Thanks!

1 Like

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