as of now i am sending string text as email body.but i should send Ok,cancel button and some text.if user click on Ok need to do some functionality .if cancel need to open a textbox.please tell me ..
-
4Look at emails you get from Facebook and explore their HTML. Don't mess with JavaScript in emails. Every button should link to a web page that does something. – Ofer Zelig Dec 27 '12 at 09:51
-
1You will need to use HTML emails for this. Assuming you are using the basic .NET emailer I think this means setting IsHTML property to true on the email body object. that having been said its not clear if your problem is the HTML or telling .NET to send as HTML. Some code and some clearer explanation of where you are stuck might help. – Chris Dec 27 '12 at 09:53
-
anyone please tell me i am sending html content placed 2 buttons.how to handle their click events? – user1237131 Dec 27 '12 at 10:19
-
@user1237131 As I said in my answer, you can't – Blachshma Dec 27 '12 at 10:57
3 Answers
look at here
you should Generate your HTML code like this :
mm.Body = "<h2>This is an HTML-Formatted Email Send Using the <code>IsBodyHtml</code> Property</h2><p>Isn't HTML <em>neat</em>?</p><p>You can make all sorts of <span style=""color:red;font-weight:bold;"">pretty colors!!</span>.</p>";
mm.IsBodyHtml = true;

- 1
- 1

- 10,654
- 14
- 63
- 110
You won't be able to run any scripts since most mail clients block this nowadays. If you want to include buttons in your emails, you'll have to insert images with links to a public web page of yours.
To understand who is the user who clicked on the link, you should also include some unique Guid in the URL...
Since many mail clients nowadays even refuse to load remote images, you might need to embeed the images inside the email.
Anyways, an example of such a "remote callback" could be something like this:
<a href="http://mywebsite.com/buttonclick.aspx?ClickId=[SomeUniqueGuid]><img src="http://mywebsite.com/image.png"></a>
But just to make it clear - you have NO WAY of popping up textboxes or adding scripts unless your invent your own mail client

- 17,097
- 4
- 58
- 72
i have wrote a function to send html based emails .
string mbody may contain html. Which can include button or text boxes as well. in my case i have used stringbulder to build body of email.
private string styleTag = "<head><STYLE TYPE='text/css'>body, input, button{color:
black;background-color: white;font-family: Verdana,Arial,Helvetica;font-size: x-
small;}p{color: #666666;}h1{color: #666666;font-size: medium;}h2{color:
black;}table{border-collapse: collapse;border-width: 0;border-spacing: 0;width: 90%;table-
layout: auto;}pre{word-wrap: break-word;font-size: x-small;font-family:
Verdana,Arial,Helvetica;display: inline;}table.WithBorder{border-style: solid;border-color:
#F1EFE2;border-width: 1px;border-collapse: collapse;width: 90%;}TD{vertical-align:
top;font-size: x-small;}TD.PropName{vertical-align: top;font-size: x-small;white-space:
nowrap;background-color: #FFF;border-top: 1px solid #F1EFE2;}TD.PropValue{font-size: x-
small;border-top: 1px dotted #F1EFE2;}TD.Col1Data{font-size: x-small;border-style:
solid;border-color: #F1EFE2;border-width: 1px;background: #F9F8F4;width:
auto;}TD.ColData{font-size: x-small;border-style: solid;border-color: #F1EFE2;border-width:
1px;}TD.ColDataXSmall{font-size: x-small;border-style: solid;border-color: #F1EFE2;border-
width: 1px;width: 5%;}TD.ColDataSmall{font-size: x-small;border-style: solid;border-color:
#F1EFE2;border-width: 1px;width: 10%;}TD.ColHeadingXSmall{background-color: #F1EFE2;border-
style: solid;border-color: #F1EFE2;border-width: 1px;font-size: x-small;width:
5%;}TD.ColHeadingSmall{background-color: #F1EFE2;border-style: solid;border-color:
#F1EFE2;border-width: 1px;font-size: x-small;width: 10%;}TD.ColHeadingMedium{background:
#F1EFE2;border-style: solid;border-color: #F1EFE2;border-width: 1px;font-size: x-
small;width: 200px;}TD.ColHeading{font-size: x-small;border-style: solid;border-color:
#F1EFE2;border-width: 1px;background: #F1EFE2;width: auto;}.Title{width:100%;font-size:
medium;}.footer{width:100%;font-size: xx-small;}</STYLE></head>";
public string SendEmail(string mTo, string mSubject, string mBody)
{
string host = "xxx";
string str2 = "xxx";
string userName = "xxx";
string password = "xxx";
SmtpClient client = new SmtpClient(host) {
Port = 0x1b,
Credentials = new NetworkCredential(userName, password)
};
MailAddress from = new MailAddress(str2, userName, Encoding.UTF8);
MailAddress to = new MailAddress(mTo);
MailMessage message = new MailMessage(from, to) {
IsBodyHtml = true,
Body = mBody,
Subject = mSubject
};
client.Send(message);
return "email sent";
}

- 1,961
- 2
- 32
- 49

- 59
- 1
- 4