how to create a dynamic email from variable

T

tirrell payton

Hello,

I am attempting to validate my user's email addresses by sending them a
link. However, I am having trouble concatenating the variable name (GUID)
into the url. Im using C#:

public void SendSignupEmail(string emailaddress, string customerid)
{
SmtpClient mysmtpclient = new SmtpClient();
MailMessage mymailmessage = new MailMessage();
MailAddress mymailaddress = new MailAddress("(e-mail address removed)",
"Signup");
mysmtpclient.Host = "smtp.domain.com";
mysmtpclient.Port = 25;
mymailmessage.From = mymailaddress;
mymailmessage.To.Add("(e-mail address removed)");
mymailmessage.Subject = "Thank you for signing up";
mymailmessage.IsBodyHtml = true;

//this is the part where I am having problems, I want to put the
customerid in the url, but I dont know the syntax
mymailmessage.Body = "<p><a
href='http://www.domain.com/confirmation.aspx?customerid=&customerid'click
here to validate your signup</a></p>";
mysmtpclient.Send(mymailmessage);
}
 
T

tirrell payton

Mark,

How do I write out the url with the variable in it? Thats the part im
having trouble with.

-Tirrell
 
T

tirrell payton

Mark,

When I try this I get:
Operator '&' cannot be applied to operands of type 'string' and 'string'
 
N

Nitin

tirrell said:
Hello,

I am attempting to validate my user's email addresses by sending them a
link. However, I am having trouble concatenating the variable name (GUID)
into the url. Im using C#:

public void SendSignupEmail(string emailaddress, string customerid)
{
SmtpClient mysmtpclient = new SmtpClient();
MailMessage mymailmessage = new MailMessage();
MailAddress mymailaddress = new MailAddress("(e-mail address removed)",
"Signup");
mysmtpclient.Host = "smtp.domain.com";
mysmtpclient.Port = 25;
mymailmessage.From = mymailaddress;
mymailmessage.To.Add("(e-mail address removed)");
mymailmessage.Subject = "Thank you for signing up";
mymailmessage.IsBodyHtml = true;

//this is the part where I am having problems, I want to put the
customerid in the url, but I dont know the syntax
mymailmessage.Body = "<p><a
href='http://www.domain.com/confirmation.aspx?customerid=&customerid'click
here to validate your signup</a></p>";
mysmtpclient.Send(mymailmessage);
}
try string.format instead
e.g
mymailmessage.Body= string.format("<p><a
href='http://www.domain.com/confirmation.aspx?customerid={0}'>Click here
to validate your email</a>",customerid)

I hope it helps,
Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,146
Latest member
Vinay KumarNevatia_
Top