ASP.NET - Add Email Message to Outlook Draft Folder with Attachements

I was recently looking for a way to add an email to a user's draft folder with attachements. Exchange web services was the ticket.  See the screen shot and code snippet attached.

The trick is to add to a user's outlook draft folder you need a user id with higher level rights and allow impersonation must be turned on in Exchange.

using System.DirectoryServices;
using Microsoft.Exchange.WebServices.Data;

namespace ExchangeWSTest
{
    public partial class ActiveXTest : System.Web.UI.Page
    {       
              
        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
        protected void Page_Load(object sender, EventArgs e)
        {
            service.Credentials = new WebCredentials("youremail", "yourpassword");
            service.Url = new Uri("https://client.yourexchangeserver.com/ews/exchange.asmx");           
        }

        protected void BtnCreateMsg_Click(object sender, EventArgs e)
        {          
            EmailMessage message = new EmailMessage(service);
            message.Subject = TxtSubject.Text;

            string MSG = TxtBody.Text;
            MSG = MSG.Replace("\n", "
"); message.Body = MSG; message.Attachments.AddFileAttachment(@"C:\temp\TEST Word Doc.docx"); message.Attachments.AddFileAttachment(@"C:\temp\TestPDF.pdf"); message.Save(); LblMsg.Text = "Email created, please check your draft folder"; } } }

Bind Generic List to ASP.NET DropDownBox (or GridView)

//Class for generic list
public class MarketDates
{
    public string DisplayDate { get; set; }
    public string SelectDate { get; set; }
}

 //List for binding
List LstFromDate = new List();
List LstToDate = new List();

//Load List
for (int i = 1999; i < (DateTime.Now.Year + 1); i++)
{
   MarketDates DDLFromDate = new MarketDates();
   MarketDates DDLToDate = new MarketDates();

   DDLFromDate.DisplayDate = "JAN-" + i.ToString();
   DDLFromDate.SelectDate = i.ToString();
   LstFromDate.Add(DDLFromDate);

   DDLToDate.DisplayDate = "DEC-" + i.ToString();
   DDLToDate.SelectDate = i.ToString();
   LstToDate.Add(DDLToDate);
}

//Bind
DDLFromYear.DataTextField = "DisplayDate";
DDLFromYear.DataValueField = "SelectDate";
DDLFromYear.DataSource = LstFromDate;
DDLFromYear.DataBind();
     
DDLToYear.DataTextField = "DisplayDate";
DDLToYear.DataValueField = "SelectDate";
DDLToYear.DataSource = LstToDate;
DDLToYear.DataBind();  

Scrolling GridView - Retain Scroll Position on Postback

The cleanest example I have seen for this feature is by Sergey Akopov.

Sergey implement a jQuery example that works wonderfully! Here is the link to the article. I attached the ZIP file same code, which is on Sergey's site as well.

MaintainScroll.zip (3.01 kb)

Here is a link to a pure JavaScript example (older 2006). I have not tried it out but wanted to save the link as another example.