JQuery Reverse each loop.
Nov 26, 2012
Aug 23, 2012
In Asp.net, how do I embed images in an email?
Kalpesh Satasiya 6:58 PM ahmedabad, asp.net, Email with Embed Image, Embed Image, india, software developer, software development 4 comments
static void EmbedImages()
{
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@mycompany.com");
mail.To.Add("you@yourcompany.com");
//set the content
mail.Subject = "This is an email";
//first we create the Plain Text part
AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", null, "text/plain");
//then we create the Html part
//to embed images, we need to use the prefix 'cid' in the img src value
//the cid value will map to the Content-Id of a Linked resource.
//thus <img src='cid:companylogo'> will map to a LinkedResource with a ContentId of 'companylogo'
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image.<img src=cid:companylogo >", null, "text/html");
//create the LinkedResource (embedded image)
LinkedResource logo = new LinkedResource( "c:\\temp\\logo.gif" );
logo.ContentId = "companylogo";
//add the LinkedResource to the appropriate view
htmlView.LinkedResources.Add(logo);
//add the views
mail.AlternateViews.Add(plainView);
mail.AlternateViews.Add(htmlView);
//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1"); //specify the mail server address
smtp.Send(mail);
}
Aug 8, 2012
How Parse XML Using Regular Expressions in Asp.net with C#
Kalpesh Satasiya 12:55 PM ahmedabad, asp.net, software developer, software development, XML Parse 1 comment
Hello Friends,
I got good solution for XML element value find from XML string.
Need to just call this function with parameters XML string, XML element name and default value if value not find into XML string.
private String ExtractContentFromXml(String xml, String element, String defaultValue)
{
String RegExpression = String.Format(@"(?<={0}>)[\S\s]*?(?=\<\/{0})", element);
Match ThisMatch = Regex.Match(xml, RegExpression);
if (ThisMatch.Success)
return ThisMatch.Value;
else
return defaultValue;
}
I hope you will enjoy this solution...