user2932408
user2932408

Reputation: 65

New Line / Carriage Return in C# Generated Outlook Email

Maybe outlook is just formatting this to be the way Outlook wants it to look, bc the code looks good to me, maybe one of you gurus can tell me how to add a carriage return (Have the next previous employer appear on the next line)

Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem         
(Outlook.OlItemType.olMailItem);                
string content = string.Empty;
string content = previousEmployer + Environment.NewLine;
//I have also tried this to no avail
//string content = previousEmployer + "\n";
oMsg.HTMLBody = content;
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("alphaomegaentry.com");
oRecip.Resolve();
oMsg.Save();
oRecip = null;
oRecips = null;
oMsg = null;
oApp = null;

Upvotes: 2

Views: 3092

Answers (1)

JMK
JMK

Reputation: 28059

If HTMLBody indeed needs to contain HTML, you could try this:

string content = string.Format("{0}<br />", previousEmployer);
oMsg.HTMLBody = content;

Upvotes: 3

Related Questions