embed image to body in html email in asp.net - asp.net

How shall i write the code to embed image to email body? whats wrong?
mMailMessage.Body += Server.MapPath(#"<img src=""/Styles/Images/logo.png""");
.

You are mapping a path to a file called "<img src=""/Styles/Images/logo.png"""!
What you want to do is something like this:
mMailMessage.Body += "<img src=\"" + Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + #"/Styles/Images/logo.png" + "\"/>";

Related

Change asp message box header / title

How can I change the title of my message box
Here is my code-behind:
string myStringVariable1 = string.Empty;
myStringVariable1 = "Policy Number:" + " " + txtPolNo.Text.ToString() + " " + "with Issuance office:" + " " + dropIssOff.Text.ToString() + " " + "was not found on the database. Please make sure that your inputs are correct.";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable1 + "');", true);
No, You can't change that title. Alternatively you can use the jQuery alert/dialog box to achieve the same.

Drag&Drop Grouping Animation Not Working

I enabled grouping on my RADGrid, but when I Drag & Drop a column, all I see is a "CrossHair" cursor while dragging. I do not see the animation visually showing a box representing the column being dragged, nor do I see the "double arrow" that appears showing you where the column is about to be dropped. Both these features I saw on the Telerik RADGrid Demo's, but I can seem to replicate this feature on my own RADGrid.
Help!
try the following link. This will help you getting the drag n drop working.
Iam using this method currently, too. My DNN is Version 6.x
http://www.telerik.com/community/forums/aspnet-ajax/grid/unknown-server-tag-telerik-griddragdropcolumn.aspx
*EDIT:
Call the following method in your Page_Load (this is only to get the script block dynamically on the page. You have to to the described steps in my link, too):
public void subDragDropJavaScript()
{
// define the script string to add to the page
StringBuilder sJavaScript = new StringBuilder();
// js header
sJavaScript.Append(("<script type=\'text/javascript\'>" + "\r\n"));
sJavaScript.Append("function startRowDrag_ModuleID_"+ this.ModuleId + "_GridID_" + oDNNGrid.ID + "(row, args)" + "\r\n");
sJavaScript.Append("{" + "\r\n");
sJavaScript.Append("var target = args.target || args.srcElement;" + "\r\n");
sJavaScript.Append("if (target.className.indexOf('rgDrag') > -1)" + "\r\n");
sJavaScript.Append("{" + "\r\n");
sJavaScript.Append("args._isDragHandle = true;" + "\r\n");
sJavaScript.Append("var tableView = $find(row.id.split('__')[0]);" + "\r\n");
sJavaScript.Append("var grid = $find(tableView.get_owner().get_id());" + "\r\n");
sJavaScript.Append("tableView.get_dataItems();" + "\r\n");
sJavaScript.Append("$find(row.id).set_selected(true);" + "\r\n");
sJavaScript.Append("var origFunc = Telerik.Web.UI.RadGrid.prototype._canRiseRowEvent;" + "\r\n");
sJavaScript.Append("Telerik.Web.UI.RadGrid.prototype._canRiseRowEvent = function ()" + "\r\n");
sJavaScript.Append("{" + "\r\n");
sJavaScript.Append("var el = arguments[0].target || arguments[0].srcElement;" + "\r\n");
sJavaScript.Append("return origFunc.apply(grid, arguments) || el.tagName.toLowerCase() == 'img';" + "\r\n");
sJavaScript.Append("}" + "\r\n");
sJavaScript.Append("grid._mouseDown(args);" + "\r\n");
sJavaScript.Append("Telerik.Web.UI.RadGrid.prototype._canRiseRowEvent = origFunc;" + "\r\n");
sJavaScript.Append("}" + "\r\n");
sJavaScript.Append("}" + "\r\n");
sJavaScript.Append("function gridRowDragStarted_ModuleID_" + this.ModuleId + "_GridID_" + oDNNGrid.ID + "(sender, args) {" + "\r\n");
sJavaScript.Append("if (!args.get_domEvent()._isDragHandle) {" + "\r\n");
sJavaScript.Append("args.set_cancel(true);" + "\r\n");
sJavaScript.Append("}" + "\r\n");
sJavaScript.Append("}" + "\r\n");
// js close block
sJavaScript.Append("</script>");
// add js block to page
this.Page.ClientScript.RegisterStartupScript(typeof(string), "DragnDropRowSelection_" + ModuleId, sJavaScript.ToString());
}
best regards,
noone
I know this is an old thread but I just recently found my answer.
In the Module.css of my custom module, I added the following code:
.RadGrid
{
z-index: 1000;
}
Apparently the default.css of the DNN framework makes the z-index of the module higher than the grid, which covers up the animation. Increasing the z-index to the grid itself places it above the module and thereby allows the animation to display once again.

Posting text with link to facebook wall using C# sdk

I am using facebook api for posting to the facebook wall post.THe post is getting displayed in the wall but i am not able to show the link which redirects to the site when it is clicked.
I need to show both the post as well as the link which points the posted post.
Following is my code
string viewDetailsLink = context.Url.GetLeftPart(UriPartial.Authority).ToString();
viewDetailsLink = viewDetailsLink + "/" + "Blog" + "/Index/" + "0/" + blogPost.Id;
viewDetailsLink = "<a href='" + viewDetailsLink + "'/>" + "click here to open" +"</a>";
But the whole thing is displayed as string instead of click here to open.
How do i resolve this?
You're seeing text instead of a link because you're closing our anchor tag prematurely. Try this instead:
viewDetailsLink = "<a href='" + viewDetailsLink + "'>click here to open</a>";
Here is the issue with your code:
viewDetailsLink = "<a href='" + viewDetailsLink + "'/>" + "click here to open" +"</a>";
Shouldn't close tag here ^ ^ No need to concat ^
Your code, fixed and prettied up a bit:
string viewDetailsLink = context.Url.GetLeftPart(UriPartial.Authority).ToString();
viewDetailsLink = String.Format("{0}/Blog/Index/0/{1}", viewDetailsLink, blogPost.Id);
viewDetailsLink = String.Format("<a href='{0}'>click here to open</a>", viewDetailsLink);

email hyperlink in MailMessage

I'm using the following as part of sending a .net 4 email. I'd like to show the reply to text as an email hyperlink but can't quite get the format correct.
nMail.Body = Description " + txtdescription.Text +
"<br />Reply to (click here):" + txtemail.Text);
Wrap the address in an anchor tag <a> to make a link. Also make sure you encode the input.
Use HttpUtility.HtmlEncode on text and Uri.EscapeUriString on links.
nMail.Body = "Description " +
HttpUtility.HtmlEncode(txtdescription.Text) +
"<br />Reply to <a href=\"mailto:" +
Uri.EscapeUriString(txtemail.Text) +
"\">" +
HttpUtility.HtmlEncode(txtemail.Text) +
"</a>");
Use the following if the e-mail address is contained in txtemail.Text. Remember to first validate the content of txtemail.Text. The output of the following is a hyperlink to an e-mail address that also contains the e-mail address as the hyperlink text.
nMail.Body = "Description " + txtdescription.Text + "<br />Reply to (click here): " + "<a href='mailto:" + txtemail.Text + "'>" + txtemail.Text + "</a>");
You can write <a href='mailto:username#example.com'>Link Text</a>.
Try this
private string BuildEmailText(string description, string replyToAddress, string replyToText)
{
return string.Format("{0} <a href='{1}'>{2}</a>", description, replyToAddress, replyToText);
}

Error while sending mail (attachment file)

in my application i am using to send mail with attachments i write the code like this
Using System.Net.Mail;
MailMessage mail = new MailMessage();
mail.Body = "<html><body><b> Name Of The Job Seeker: " + txtName.Text + "<br><br>" + "The Mail ID:" + txtEmail.Text + "<br><br>" + " The Mobile Number: " + txtmobile.Text + "<br><br>" + "Position For Applied: " + txtPostionAppl.Text + "<br><br>" + "Description " + txtdescript.Text + "<br><br></b></body></html>";
mail.From = new MailAddress ( txtEmail.Text);
mail.To .Add (new MailAddress ( mailid));
mail.Priority = MailPriority.High;
FileUpload1.PostedFile.SaveAs("~/Resume/" + FileUpload1.FileName);
mail.Attachments.Add(filenme);
SmtpMail sm = new SmtpMail();
sm.Send(mail);
it is giving error at attachment like mail.Attachemts.Add(filena)
like this
'System.Collections.ObjectModel.Collection.Add(System.Net.Mail.Attachment)' has some invalid arguments.
Your syntax is wrong. See this article for the correct syntax,
http://www.systemnetmail.com/faq/2.3.aspx
You can't add an attachment simply by specifying the filename. You have to specifically create an attachment object and add that. (as shown in the linked article.)
like this:
mail.Attachments.Add(new Attachment(filename));

Resources