I want to create a string with string.format, but the format must be editable.
Therefor i want to add the format in app.config and read it from the program and enter the correct values in it.
This is my app.config-file:
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="utf-16" ?>
- <configuration>
- <appSettings>
- <!-- SimpleMailAddin settings -->
- <!-- MailSender, SMTPServer and MailBodyFormat are required -->
- <add key ="MailSender" value ="me@mydomain.com"/>
- <add key ="SMTPServer" value ="VMEXCH.mydomain.com"/>
- <!-- This is the foSystermatstring of the body of the message. Usable values : {0} = Event_ID {1} = Event_Name {2} = Event_StartDate {3} = Event_EndDate {4} = Event_Description -->
- <add key="MailBodyFormat" value="Event Reminder\n\nEvent : {1} ({0})\nStartdate : {2}\nEnddate : {3}\n\n{4}"/>
- </appSettings>
- </configuration>
Expand|Select|Wrap|Line Numbers
- string body = System.Configuration.ConfigurationManager.AppSettings["MailBodyFormat"];
- body = string.format(body, Event_ID, Event_Name, Event_StartDate, Event_EndDate, Event_Description);
Any way to solve this?