I am trying to create a project that gets the body of an email then dumps it into a notepad. My problem is, how can I replace the title of the notepad as month+date+year_hours+minutes+seconds without the separators(or with period as a separator) coz we all know that the separators can’t be a title at notepad. the title should be like this; 12172018_225834 or 12.17.2018_22.58.34
are you asking how do you put the filename or date string in the Selector so it will dump the data into the correct notepad window?
You’ll need to edit the selector as an expression and concatenate the values in the title attribute. You can either store your date time into a variable prior or place the date time directly in the selector.
It will end up looking something like this: Assign timestamp = Now.ToString("MM.dd.yyyy_HH.mm.ss") "<wnd app='notepad.exe' cls='Notepad' title='*"+timestamp+"*' /><wnd cls='Edit' />"
or "<wnd app='notepad.exe' cls='Notepad' title='*"+Now.ToString("MM.dd.yyyy_HH.mm.ss")+"*' /><wnd cls='Edit' />"
To add to @ClaytonM’s answer, you can also use the format Now.ToString("MMddyyyy_hhmmss" for the alternate format when assigning to the timestamp variable to use as the filename for the notepad.
Hi Clayton, my plan is to copy the body of an email, and dump it into an untitled notepad then have the filename of the notepad consist of the timestamp of the email, I think i will be using the mail.Headers(“Date”), can I change the timestamp to Date instead of Now? Coz I think “Now” uses the current date and time?
Yeah. You can use mail.Headers(“Date”), but you just need to parse it to a date so you can format it the way you want. If it is in the “MM/dd/yyyy” format then you can just use Convert.ToDate() or CDate()
So, replace Now with this: Convert.ToDate(mail.Headers("Date").ToString)
If the date is in the “dd/MM/yyyy” format, then you’ll need to use ParseExact()
I believe it would look like this: DateTime.ParseExact( mail.Headers("Date").ToString, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture)
If I made a mistake on that, there are examples of this on the forum or online
Then, you can format it just like I showed, like .ToString(“MMddyyyy_HHmmss”)
Keep in mind, that “hh” is 12hour format and “HH” is 24hr.
I’m trying to change it like this. timestamp = mail.Headers(“Date.”.ToString(“MM-dd-yyyy_HH-mm-ss”)), but it returns an error like this one. Sorry, really a newbie here.
I used a message box to display the contents. Basically it’s the time stamp of when the unread email is received as to what my process flow should be doing.
you can assign it to a variable like i did ‘datevar’ Regex.Replace(datevar,"[/|:]",".").Replace(" ","_")
or you can simply use the expression: Regex.Replace(mail.Headers(“Date”).ToString,"[/|:]",".").Replace(" ","_")