I am trying to insert a table in email but it only shows the syntax on the message body of the email.
Attached is the output;
mail.Subject = "Blah Service Alert - " + application + " Upgrade (Day, Month, Year)";
mail.Body = "Dear Customer," + Environment.NewLine + Environment.NewLine +
"I would like to provide notice that we will be carrying out an Upgrade on the " + application + " on (Day, Month, Year)." + Environment.NewLine + Environment.NewLine +
"Blah Essential Maintenance Downtime Window 2019" + Environment.NewLine + Environment.NewLine +
"System: " + application + Environment.NewLine + Environment.NewLine +
"<table><tr>" +
"<th> Downtime Start </th>" +
"<th> Downtime Start </th>" +
"<th> Downtime End </th>" +
"<th> Downtime End </th>" +
"</tr> <tr>" +
"<td> Date: </td" +
"<td> Time: </td>" +
"<td> Date: </td>" +
"<td> Time: </td>" +
"</tr></table>" + Environment.NewLine + Environment.NewLine +
You need to set MailMessage.IsBodyHtml Property to true, assuming that you're using MailMessage class.
Assuming you are using the Outlook Object Model, set the MailItem.HTMLBody property rather than the plain text MailItem.Body.
Related
listBox2.Items.Add(c[n].nume_proprietar + ", " + c[n].nume_catel + ", " + c[n].varsta + " ani , " + c[n].data_vaccin + " " + c[n].tip_vaccin);
Hi, I was wandering if i could insert a line in between " ani , " and c[n].data_vaccin so that my code will display on 2 different lines, obviously with the vallues i insert when i will run the program:
c[n].nume_proprietar ", " c[n].nume_catel ", " c[n].varsta + " ani , " and on another line
c[n].data_vaccin " " c[n].tip_vaccin
Insert Environment.NewLine where you want to breakline. It is environment specific and provides clarity over "\r\n" hence it's preferred to use.
listBox2.Items.Add(c[n].nume_proprietar + ", " + c[n].nume_catel + ", " + c[n].varsta + " ani ," + Environment.NewLine + c[n].data_vaccin + " " + c[n].tip_vaccin);
I want to fetch history from browser as soon as a web site is loaded in the browser. It should fetch clients' browser info and save it in a database so that admin may check out the website that is frequently opened and can do survey on the data.
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
+ "Type = " + browser.Type + "\n"
+ "Name = " + browser.Browser + "\n"
+ "Version = " + browser.Version + "\n"
+ "Major Version = " + browser.MajorVersion + "\n"
+ "Minor Version = " + browser.MinorVersion + "\n"
+ "Platform = " + browser.Platform + "\n"
+ "Is Beta = " + browser.Beta + "\n"
+ "Is Crawler = " + browser.Crawler + "\n"
+ "Is AOL = " + browser.AOL + "\n"
+ "Is Win16 = " + browser.Win16 + "\n"
+ "Is Win32 = " + browser.Win32 + "\n"
+ "Supports Frames = " + browser.Frames + "\n"
+ "Supports Tables = " + browser.Tables + "\n"
+ "Supports Cookies = " + browser.Cookies + "\n"
+ "Supports VBScript = " + browser.VBScript + "\n"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "\n"
+ "Supports Java Applets = " + browser.JavaApplets + "\n"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "\n";
Request.Browser is used to identify the browser info . Using this you can get all info of browser
IIS is already storing this information for you. See: http://msdn.microsoft.com/en-us/library/ms525410%28v=vs.90%29.aspx
To make that data useful you will then need to use a Log Analyzer tool.
Google this term for some options to use: iis log analyzer
I am trying to include the text written by enduser in a textfield in an InfopathForm (textfield,multiline,paragraphbreaks and scroll bar if necessary) in an email to the relevant Department.
I always get this error "The name 'remarkmain' does not exist in the current context"
these are some parts of the code i used to define and include in mail:
string remarkmain = xnMyForm.SelectSingleNode("/my:myFields/my:field104", ns).Value;
string BodyAcc = "New Internal Employee " + Titlee + " " + fullname + ".\n Employee is joining " + Comp + " as of " + HireDate + ".\n\n Please view the general information below:\n " + bodyHD + "\n" + bodyED + "\n" + bodyDOB + "\n" + bodytitle + "\n" + bodylast + "\n" + bodyname + "\n" + bodyLang + "\n" + bodyComp + "\n" + bodydep + "\n" + bodyPos + "\n" + Bankacc + "\n" + add + "\n" + CostCtreVZW + "\n" + CostCtreCVBA + "\n\nWork Schedule\n" + WorkMon + "\n" + WorkTue + "\n" + WorkWed + "\n" + WorkThurs + "\n" + WorkFri + "\n" + WorkFDSch + "\n\n" + ContractN + "\n" + EmpN + "\n" + MGR + "\n" + Teamlead +"\n\n" **+ remarkmain** + "\n\n";
I am new to c# and this form i m creating in Infopath ( 2007 )
Have you considered submitting certain values to a form library and using sharepoint workflows via sharepoint designer to send the mail? The sharepoint workflow variable selection and general interface is generally expansive and pleasant and the functionality is extensive.
See to that strign BodyAcc="New Internal Employee+....remarkmain+....; is in remarkmain scope
Use StringBuilder if you have too many string concatinations
StringBuilder BodyAcc = new StringBuilder
BodyAcc.Append(New Internal Employee);
BodyAcc.Append("\n");
BodyAcc.Append(remarkmain);
I am creating a form in ASP.NET C# so it can be filled out and emailed to multiple recipients. Part of the form is a checkbox section with multiple options. I can only get the first option selected to be emailed back to the recipients, so if the user selects two or more checkboxes, it only emails the first option. Below is my code sheet
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress From = new MailAddress(mailTextBox.Text);
message.To.Add(new MailAddress("email#domain.com"));
message.Subject = (companyTextBox.Text);
message.IsBodyHtml = true;
message.Body = "<html><head></head><body>" +
"<p></p>" +
"<p>Business Type: " + typeDropDownList.Text + "</p>" +
"<p>Company: " + companyTextBox.Text + "</p>" +
"<p>Name: " + nameTextBox.Text + "</p>" +
"<p>Address: " + addressTextBox.Text + "</p>" +
"<p>City: " + cityTextBox.Text + "</p>" +
"<p>State: " + stateDropDownList.Text + "</p>" +
"<p>Zip Code: " + zipcodeTextBox.Text + "</p>" +
"<p>Phone Number: " + phoneTextBox.Text + "</p>" +
"<p>Email: " + mailTextBox.Text + "</p>" +
"<p>Number Of Locations: " + locationsDropDownList.Text + "</p>" +
**// This is my problem area //**
"<p>Interested In: " + interestedCheckBoxList.Text + "</p>" +
"<p>Interested In: " + interestedCheckBoxList.Text + "</p>" +
"<p>Interested In: " + interestedCheckBoxList.Text + "</p>" +
**// This is my problem area //**
"<p>Message: " + messageTextBox.Text + "</p>" +
"</body></html>";
smtpClient.Send(message);
Response.Redirect("http://www.domain.com");
Thank you in advance.
Jim
You will need to loop through the Items in the CheckBoxList and add them individually.
Example:
foreach(ListItem li in interestedCheckBoxList.Items)
{
//add your stuff
if(li.Selected)
{
//should be using string builder here but....
message.Body += "<p>Interested In: " + li.Text + "</p>";
}
}
You need to iterate through your CheckBoxList and find all the checked items and get the Text property for each item and append to you email text.
string yourSelectedList = "";
foreach (ListItem i in chklst.Items)
{
if (i.Selected)
yourSelectedList += (i.Text + ", ");
}
Then remove the extra comma at the end :)
"<p>Interested In: " + yourSelectedList + "</p>" +
Try to use StringBuilder when concatentating many strings together as it will make a big difference.
Try replacing the code in your "problem area" with the following:
string InterestedIn = "";
foreach (ListItem li in interestedCheckBoxList.Items)
{
if (li.Selected)
InterestedIn += "<p>Interested In: " + li.Text + "</p>";
}
Of course, you can't concatenate this as part of your original string concatenation, so build an "InterestedIn" string of sorts and concatenate the email body with that.
Im trying to access and extract message from Exchange Server 2003. I need to get them by dates but im having problem with it.
Here's the code lsQuery = "<?xml version=\"1.0\"?>"
+ "<D:searchrequest xmlns:D = \"DAV:\" xmlns:m=\"urn:schemas:httpmail:\">"
+ "<D:sql>SELECT \"urn:schemas:httpmail:hasattachment\", \"DAV:displayname\", "
+ "\"urn:schemas:httpmail:from\", \"urn:schemas:httpmail:subject\", "
+ "\"urn:schemas:httpmail:htmldescription\" FROM \"" + lsRootUri
+ "\" WHERE \"DAV:ishidden\" = false "
+ "AND \"DAV:isfolder\" = false "
+ "AND \"urn:schemas:httpmail:hasattachment\" = true "
+ "AND \"urn:schemas:httpmail:read\" = false "
+ "AND \"urn:schemas:httpmail:date \" \">=\" CAST(\"2009/11/17\" as 'dateTime') "
+ "AND \"urn:schemas:httpmail:date \" \"<=\" CAST(\"2009/11/19\" as 'dateTime') "
+ "</D:sql></D:searchrequest>";
http://msdn.microsoft.com/en-us/library/aa123600%28EXCHG.65%29.aspx