This area of the website is no longer being updated.
Changes and news are now published on this page.

How to correct the email date/time to the required time zone

January 8, 2019

Email Parser automatically uses your local time (as set in Windows) to give a value to the fields DateTimeSent and DateTimeProcessed. But you may need to have these times adjusted to UTC+0 time or another time zone. For this you need to use a small script:

As you can see in the screenshot above, the script takes the value of DateTimeSent, available in any email by default, and adds or subtracts the number of hours set in the hours_difference variable. Here is the full script, you only need to copy/paste it in a new field inside a Parser:

using System;
using System.Text;
using System.IO;
using System.Collections.Generic;
using EmailParserBackendApi.ScriptingInterface;

public class MyScriptBasedEmailParser : ScriptBasedParser
    public override List ExtractTextFrom(string input_text)
        // Enter a positive or negative amount
        // of hours to do the time zone correction
        int hours_difference = -2;
        List captured_values = new List();

            DateTime date_time_sent = DateTime.Parse(input_text);
            captured_values.Add((date_time_sent + TimeSpan.FromHours(hours_difference)).ToString());
        catch(Exception ex)
             captured_values.Add("Error. "+ex.Message);
        return (captured_values);

© 2008-2024 Triple Click Software
News & Updates

Privacy Policy & Terms of Use
PAD file·Old news