Beispiel #1
0
        public void ImmediateReply(object item, SendCondition condition)
        {
            Microsoft.Office.Interop.Outlook.MailItem mailItem = item as Microsoft.Office.Interop.Outlook.MailItem;
            if (mailItem == null)
            {
                throw new Exception("ImmediateReply: mailItem is undefined.");
            }


            string body = CreateResponseBody(mailItem.Subject.ToLower(), mailItem.Sender.Name, condition);


            if (body == null)
            {
                return;
            }

            Microsoft.Office.Interop.Outlook.MailItem reply = mailItem.ReplyAll();
            reply.HTMLBody = AdjustText(reply.HTMLBody);

            reply.HTMLBody = body + reply.HTMLBody;

            reply.Attachments.Add(this.attachmentFileName);

            if (condition == SendCondition.Conditional)
            {
                reply.Display();
            }
            else
            {
                reply.Send();
            }

            //mailItem.HTMLBody = string.Format( "<font size='1' color='red'><div id='replysent' > Reply sent on: {0}</div><font><br>", System.DateTime.Now.ToShortDateString() ) + mailItem.HTMLBody;
            //font-size:14px; font-family:Times New Roman;
            mailItem.HTMLBody = string.Format("<div id='replysent' style='color:darkblue; font-size:8px; font-family:Times New Roman;' > Reply sent on: {0}</div><br>", System.DateTime.Now.ToShortDateString()) + mailItem.HTMLBody;
        }