Alex
Alex

Reputation: 44385

UnrecognizedToken Error in Powershell

I am trying to repeat the example of creating an email with inline images as shown here, but I encounter an error when using a variable $SmtpSender in the From element. The code is as follows:

$msg = new-object Net.Mail.MailMessage
$msg.From = "<a href="$SmtpSender">$SmtpSender</a>"

and the error is here:

Unrecognized token in source text.
At D:\Testing\Data\Powershell\LoadRunner\LRmain.ps1:82 char:13
+ $msg.From =  <<<< "<a href="$SmtpSender">$SmtpSender</a>"
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnrecognizedToken

The variable $SmtpSender is defined. How to fix this problem?

Upvotes: 1

Views: 1230

Answers (1)

Martin
Martin

Reputation: 1963

Just use $msg.From = $SmtpSender without the html tagging.

Upvotes: 1

Related Questions