6 Replies - 250 Views - Last Post: 19 May 2020 - 10:26 AM Rate Topic: -----

#1 DarenR   User is online

  • D.I.C Lover

Reputation: 705
  • View blog
  • Posts: 4,566
  • Joined: 12-January 10

how do you get information out of tokens?

Posted 19 May 2020 - 08:54 AM

ok so there is an emailer that someone made however they only partially made it and they used Tokens for the following fields:

 email.MailTo = TokenizeMessage(email.MailTo, obj);
            email.CC = TokenizeMessage(email.CC, obj);
            email.BCC = TokenizeMessage(email.BCC, obj);
            email.Subject = TokenizeMessage(email.Subject, obj);
            email.Message = HttpUtility.HtmlDecode(TokenizeMessage(email.Message, obj));


in the smtp it looks for something like the following:

 mail.Sender = new MailAddress(email.From == "" ? "[email protected]" : email.From);


when it hits the email.from portion of that if else above it says:
The specified string is not in the form required for an e-mail address

because it is showing the token name and not the address associated with emails
so for example it shows the following:
{EmailFrom} 

as the token but it is looking for something like
"[email protected]"


any idea how i can get it to read the tokens?

Is This A Good Question/Topic? 0
  • +

Replies To: how do you get information out of tokens?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15782
  • View blog
  • Posts: 63,261
  • Joined: 12-June 08

Re: how do you get information out of tokens?

Posted 19 May 2020 - 09:15 AM

Is 'email.from' being set anywhere?
Was This Post Helpful? 0
  • +
  • -

#3 DarenR   User is online

  • D.I.C Lover

Reputation: 705
  • View blog
  • Posts: 4,566
  • Joined: 12-January 10

Re: how do you get information out of tokens?

Posted 19 May 2020 - 09:48 AM

View Postmodi123_1, on 19 May 2020 - 12:15 PM, said:

Is 'email.from' being set anywhere?



then entire email is set like this:
TokenizeEmail(ref email, req);



oh shit i just caught that -- let me add that and test it

ok after adding email.from to the tokenizer it still has the same error

Quote

The specified string is not in the form required for an e-mail address


 public void TokenizeEmail(ref EmailsInfo email, Object obj)
        {
            email.From = TokenizeMessage(email.From, obj);

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15782
  • View blog
  • Posts: 63,261
  • Joined: 12-June 08

Re: how do you get information out of tokens?

Posted 19 May 2020 - 09:55 AM

Hmmmmmmmmmmmm... I know what I blast off emails from my app I do a few checks on separation with semicolens and checking for @s and what not.

Best bet is to deep dive into 'TokenizeMessage' and see what the heck is happening in there.
Was This Post Helpful? 0
  • +
  • -

#5 DarenR   User is online

  • D.I.C Lover

Reputation: 705
  • View blog
  • Posts: 4,566
  • Joined: 12-January 10

Re: how do you get information out of tokens?

Posted 19 May 2020 - 09:59 AM

this is all that method does:

  public string TokenizeMessage(string message, Object obj)
        {
            /*
             *Tokens:
             *(CURRENTDATE)
             *(CURRENTTIME)
             */

            message = message.Replace("(CURRENTDATE)", DateTime.Now.ToString("MM/dd/yyyy"));
            message = message.Replace("(CURRENTTIME)", DateTime.Now.ToString("h:mm tt"));

            return message;
        }


im guessing i will have to somehow add a dynamic way of adding to/from/subject etc since it looks like they dont have it in there
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15782
  • View blog
  • Posts: 63,261
  • Joined: 12-June 08

Re: how do you get information out of tokens?

Posted 19 May 2020 - 10:03 AM

That or travel upstream to see from that method call to where 'email.From' goes awry.

It's not modifying that in any significant way ('from' probably shouldn't be shoveled into it since it's not a date anyways) then further up the Congo River you must trek.
Was This Post Helpful? 0
  • +
  • -

#7 DarenR   User is online

  • D.I.C Lover

Reputation: 705
  • View blog
  • Posts: 4,566
  • Joined: 12-January 10

Re: how do you get information out of tokens?

Posted 19 May 2020 - 10:26 AM

i think "message" should be "token" or something more meaningful since it seems to grab each field individually and do a replace on it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1