473,388 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

how to create a dynamic email from variable

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("si****@domain.com",
"Signup");
mysmtpclient.Host = "smtp.domain.com";
mysmtpclient.Port = 25;
mymailmessage.From = mymailaddress;
mymailmessage.To.Add("us**@domain.com");
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);
}
Jan 20 '07 #1
7 1684
"tirrell payton" <ti******@nospam.hotmail.comwrote in message
news:45**********************@roadrunner.com...
//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);
There's no need - just write out the URL and the customer's email software
will (almost certainly) display it as a hyperlink...
Jan 20 '07 #2
Mark,

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

-Tirrell
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:us**************@TK2MSFTNGP04.phx.gbl...
"tirrell payton" <ti******@nospam.hotmail.comwrote in message
news:45**********************@roadrunner.com...
> //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);

There's no need - just write out the URL and the customer's email software
will (almost certainly) display it as a hyperlink...

Jan 20 '07 #3
"tirrell payton" <ti******@nospam.hotmail.comwrote in message
news:45**********************@roadrunner.com...
Mark,

How do I write out the url with the variable in it? Thats the part im
having trouble with.
mymailmessage.Body = "http://www.domain.com/confirmation.aspx?customerid=" &
customerid;
mymailMessage.Body += " Click the link to validate your signup";
Jan 20 '07 #4
Mark,

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

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
"tirrell payton" <ti******@nospam.hotmail.comwrote in message
news:45**********************@roadrunner.com...
>Mark,

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

mymailmessage.Body = "http://www.domain.com/confirmation.aspx?customerid="
& customerid;
mymailMessage.Body += " Click the link to validate your signup";

Jan 20 '07 #5
"tirrell payton" <ti******@nospam.hotmail.comwrote in message
news:45***********************@roadrunner.com...
Operator '&' cannot be applied to operands of type 'string' and 'string'
OK, so change it to a '+'
Jan 20 '07 #6
You are missing the closing ">" from the link and the customer id
concatanation expression is wrong.\ I think what you want to do is:

mymailmessage.Body =

String.Format("<p><a
href='http://www.domain.com/confirmation.aspx?customerid={0}'>click here to
validate your signup</a></p>", customerid);

Hope this helps,

Sagi Shkedy

http://blog.shkedy.com

"tirrell payton" <ti******@nospam.hotmail.comwrote in message
news:45**********************@roadrunner.com...
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("si****@domain.com",
"Signup");
mysmtpclient.Host = "smtp.domain.com";
mysmtpclient.Port = 25;
mymailmessage.From = mymailaddress;
mymailmessage.To.Add("us**@domain.com");
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);
}

Jan 22 '07 #7
tirrell payton wrote:
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("si****@domain.com",
"Signup");
mysmtpclient.Host = "smtp.domain.com";
mysmtpclient.Port = 25;
mymailmessage.From = mymailaddress;
mymailmessage.To.Add("us**@domain.com");
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
Jan 23 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard Price | last post by:
Hope someone can help. I am trying to write a php script that will create a text file with dynamic fields in it,save the page and then mail it as an attachment. To be more precise I want the...
3
by: eric | last post by:
Is it possible to have part of a table name used in a CREATE statement contained in a variable? Here's what I'd like to do, although obviously the syntax of this isn't quite right or I wouldn't be...
4
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure...
1
by: Devon | last post by:
Hi All, I'm generating a pdf document using FOP .25 from Apache. I've created running dynamic headings (e.g. chapter titles) that change as dictated by the XML source I'm converting to PDF. Now...
7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
4
by: Bill Sun | last post by:
Hi, All I have a conventional question, How to create a 3 dimension array by C language. I see some declare like this: int *** array; int value; array = create3Darray(m,n,l);
17
by: yinglcs | last post by:
Hi, In STL, can I create a variable size but non-growable array? In Java, I can do this: int void f (int size) { int array = new int; // do something with array return array;
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
7
by: DavidSeck.com | last post by:
Hi guys, first post :) my question: is it possible to have dynamic variable names, I mean something like this: for($i=0;$i<x;$i++){ $y_$i = blabla; }
7
by: bprocopio | last post by:
Please help. I'm stumped. I need to create a dynamic variable in a procedure that will be used to update a variable of the same name in a table. i.e. the name in tblAnalysisScores are...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.