Mail template params

I’m using the version 2.4.9 and I’m trying to setup a mail template with a parameter for the “mail to” field.
Then, in a project configuration, this parameter is initialized with a value coming from a library set.
It is failing with the following error

The specified string is not in the form required for an e-mail address.
System.FormatException: The specified string is not in the form required for an e-mail address.
at System.Net.Mail.MailAddressParser.ReadCfwsAndThrowIfIncomplete(String data, Int32 index)
at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index)
at System.Net.Mail.MailAddressParser.ParseMultipleAddresses(String data)
at System.Net.Mail.MailAddressCollection.ParseValue(String addresses)
at Octopus.Server.Orchestration.Deploy.Email.EmailActionOrchestrator.CreateMessage(SmtpConfiguration smtp, DeploymentAction action, IDeploymentManifest manifest) in y:\work\refs\heads\master\source\Octopus.Server\Orchestration\Deploy\Email\EmailActionOrchestrator.cs:line 92
at Octopus.Server.Orchestration.Deploy.Email.EmailActionOrchestrator.d__0.MoveNext() in y:\work\refs\heads\master\source\Octopus.Server\Orchestration\Deploy\Email\EmailActionOrchestrator.cs:line 48

I did a try wihtout using the library set for the “to” field and it succeeded.
How can I initialize the template parameter with a value coming from a library set?

Hi Pierre,

Thanks for getting in touch. I have been unable to replicate this. If you see my screenshots I have created a variable set, included it in my project, added a variable in the to field, and it has sent my email correctly.
So my only guess would be a scoping issue.
If you could provide similar screenshots to what I have we can try and get to the bottom of this!

Thanks!
Vanessa

emailto.PNG

Hi,

Thanks for the answer.
There’s a small difference in the way I proceed.
I created a step template for the mail

Here is the exported template

{
“Id”: “ActionTemplates-2”,
“Name”: “DNM-Content - Deploy Notification Tibco”,
“Description”: “Send deployment notification for Tibco projects.”,
“ActionType”: “Octopus.Email”,
“Version”: 6,
“Properties”: {
“Octopus.Action.Email.To”: “dcc-content@mediahuis.be”,
“Octopus.Action.Email.Subject”: “Deployment of #{Octopus.Project.Name} #{Octopus.Release.Number} to #{Octopus.Environment.Name}”,
“Octopus.Action.Email.Body”: “

\n Initiated by\n #{unless Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.Username}#{/unless}\n #{if Octopus.Deployment.CreatedBy.DisplayName}#{Octopus.Deployment.CreatedBy.DisplayName}#{/if}\n #{if Octopus.Deployment.CreatedBy.EmailAddress} (<a href=“mailto: #{Octopus.Deployment.CreatedBy.EmailAddress}”>#{Octopus.Deployment.CreatedBy.EmailAddress})#{/if}\n at #{Octopus.Deployment.Created}\n

\n#{if Octopus.Release.Notes}\n

Release notes

\n

#{Octopus.Release.Notes}

\n#{/if}\n

View the <a href=“http://grbhsttcdp02.core.local:8080/#{Octopus.Web.DeploymentLink}”>detailed deployment log.

”,
“Octopus.Action.Email.IsHtml”: “True”
},
“SensitiveProperties”: {},
“Parameters”: [
{
“Name”: “DNM-Content.Notification.Recipients”,
“Label”: “Mail To”,
“HelpText”: “coma separated list of mail addresses”,
“DefaultValue”: null
}
],
“LastModifiedOn”: “2014-07-14T08:52:05.244+00:00”,
“LastModifiedBy”: “adm_pedk01@CORE.LOCAL”,
“$Meta”: {
“ExportedAt”: “2014-07-15T06:55:43.913Z”,
“OctopusVersion”: “2.4.9.167”,
“Type”: “ActionTemplate”
}
}

Then, in the project configuration, I have a reference to it.
And, because the mail is addressed to different peoples depending on the environment, I would like to use a library set.
But it always gives an error.

Many thanks for your help,
Pierre

Hi Pierre,

Aha! It’s the dash in your variable name. I was able to successfully import your template and use a library variable (without a dash!). Dashes are evil and cause all sorts of issues like this one:
http://help.octopusdeploy.com/discussions/questions/2723-what-are-the-illegal-characters-for-a-variable-name
So we are currently implementing this:

Hope that helps!
Vanessa

Hi Vanessa,

Thanks for your help.

I removed dashes and replaced them by a “_” but I’m still facing some issues

Here is the log
Executing step: Notify
Verbose 10:01:00
Starting Run step “Notify”
Verbose 10:01:00
Loading SMTP settings
Verbose 10:01:00
Email parameters:
Verbose 10:01:00
Subject: Deployment of DNM-Content - Publication - ArticleExporter 1.0.30.3 to Tibco 5.7 DEV
Verbose 10:01:00
To: #{DNMContent_Notification_Tibco}
Verbose 10:01:00
Cc:
Verbose 10:01:00
Bcc:
Verbose 10:01:00
Failed receiving Octopus.Platform.Deployment.Messages.Deploy.Email.StartEmailActionCommand The specified string is not in the form required for an e-mail address. System.FormatException: The specified string is not in the form required for an e-mail address. at System.Net.Mail.MailAddressParser.ReadCfwsAndThrowIfIncomplete(String data, Int32 index) at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index) at System.Net.Mail.MailAddressParser.ParseMultipleAddresses(String data) at System.Net.Mail.MailAddressCollection.ParseValue(String addresses) at Octopus.Server.Orchestration.Deploy.Email.EmailActionOrchestrator.CreateMessage(SmtpConfiguration smtp, DeploymentAction action, IDeploymentManifest manifest) in y:\work\refs\heads\master\source\Octopus.Server\Orchestration\Deploy\Email\EmailActionOrchestrator.cs:line 92 at Octopus.Server.Orchestration.Deploy.Email.EmailActionOrchestrator.d__0.MoveNext() in y:\work\refs\heads\master\source\Octopus.Server\Orchestration\Deploy\Email\EmailActionOrchestrator.cs:line 48
Fatal 10:01:00
The specified string is not in the form required for an e-mail address. System.FormatException: The specified string is not in the form required for an e-mail address. at System.Net.Mail.MailAddressParser.ReadCfwsAndThrowIfIncomplete(String data, Int32 index) at System.Net.Mail.MailAddressParser.ParseAddress(String data, Boolean expectMultipleAddresses, Int32& index) at System.Net.Mail.MailAddressParser.ParseMultipleAddresses(String data) at System.Net.Mail.MailAddressCollection.ParseValue(String addresses) at Octopus.Server.Orchestration.Deploy.Email.EmailActionOrchestrator.CreateMessage(SmtpConfiguration smtp, DeploymentAction action, IDeploymentManifest manifest) in y:\work\refs\heads\master\source\Octopus.Server\Orchestration\Deploy\Email\EmailActionOrchestrator.cs:line 92 at Octopus.Server.Orchestration.Deploy.Email.EmailActionOrchestrator.d__0.MoveNext() in y:\work\refs\heads\master\source\Octopus.Server\Orchestration\Deploy\Email\EmailActionOrchestrator.cs:line 48
Verbose 10:01:00
Guided Failure is not in use for this deployment; failing.
Fatal 10:01:00
The step failed

Because you said “it works without dashes”, I got further.

I played around the library set and finally discovered where the problem was.
On the variable scope definition, I provided “roles” information.
[cid:image005.jpg@01CFA0E5.7EC9C0E0]

By removing it, everything is working fine.
It is certainly because there’s no possibility to define target in the step details screen.
[cid:image006.jpg@01CFA0E5.7EC9C0E0]
I’m not sure that this behavior is correct.
It is not because a role is defined in the variable scope and that there’s no condition on it in the step details that the variable must be rejected.

For now, I’m able to setup what I need.
I just have to be very careful with “roles“ information in variable scope definition for this kind of usage.
Can you confirm that defining a role in the scope of a variable within a library set is causing this error and that this is a normal behavior?

Thanks a lot,
Pierre

image006.jpg

image005.jpg

Hi Pierre,

I am so glad you found this! It appears the dash issue was fixed for email templates a little while ago.
Yes, due to the variable being scoped to a role, and the template step not, it would for sure come out blank.
When a Variable is scoped, it will only work for anything matching that scope. It is also why it is a good idea to have a backup non-scoped variable for these situations.

I am so happy we finally figured this out, because your template was working perfectly for me.
Vanessa