string Mailto = "username@domainname";
string MailCc = "username@domainname";
string Subject = "Test";
ReadSignature();
Outlook.Application app = new Outlook.Application();
Outlook.MailItem mail = (Outlook.MailItem)app.CreateItem(Outlook.OlItemType.olMailItem);
mail.To = Mailto;
mail.CC = MailCc;
mail.Subject = Subject;
mail.HTMLBody = "
This just a test" + signature;mail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
mail.Display(true);
I want to open a mail on buttonclick as shown above. Works perfectly.
No I'm trying to figure out how I could read out a file and use it as body.
Background: I want to have like 4 different Mails which are all formatted nicely. So I thought I could write these files as .rtf, .doc, .msg or whatsoever and just copy these files into mail.htmlbody.
Talk1:
read the html-file and assign it to mail.HTMLBody?
Solutions1
Ok right. Was pretty easy actually ;-)
//Local File
String htmlCode = File.ReadAllText(@"C:\Test.html", Encoding.Default);
//Webfile
WebClient client = new WebClient();
String htmlCode = client.DownloadString(@"http://www.google.com");
mail.HTMLBody = htmlCode + signature;
Talk1:
"htmlCode + signature" will not produced a valid HTML string. You cannot just concatenate two HTML documents, you must merge them.