Пример #1
0
        protected override void Execute(CodeActivityContext context)
        {
            Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    email = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            var    to       = To.Get(context);
            var    cc       = CC.Get(context);
            var    bcc      = BCC.Get(context);
            var    subject  = Subject.Get(context);
            string body     = (Body != null ?Body.Get(context) : null);
            string htmlbody = (HTMLBody != null ? HTMLBody.Get(context) : null);

            if (!string.IsNullOrEmpty(htmlbody))
            {
                body = htmlbody;
            }
            var attachments = Attachments.Get(context);
            var uiaction    = UIAction.Get(context);

            email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
            email.To         = to;
            email.Subject    = subject;
            email.HTMLBody   = body;
            email.CC         = cc;
            email.BCC        = bcc;

            if (attachments != null && attachments.Count() > 0)
            {
                foreach (var attachment in attachments)
                {
                    if (!string.IsNullOrEmpty(attachment))
                    {
                        email.Attachments.Add(attachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing);
                    }
                }
            }
            if (uiaction == "Show")
            {
                email.Display(true);
            }
            //else if(uiaction == "SendVisable")
            //{
            //    email.Display(true);
            //    email.Send();
            //}
            else
            {
                email.Send();
            }
            if (EMail != null)
            {
                EMail.Set(context, new email(email));
            }
        }
            protected override void Execute(CodeActivityContext context)
            {
                String  sTO         = To.Get(context);
                String  sBCC        = BCC.Get(context);
                String  sCC         = CC.Get(context);
                String  sAccount    = Account.Get(context);
                String  sBody       = Body.Get(context);
                String  sSubject    = Subject.Get(context);
                Boolean bisBodyHTML = isBodyHTML;

                String[] arrAttachment = Attachment.Get(context);
                sendOutlookMail(sTO, sCC, sBCC, sBody, sSubject, sAccount, bisBodyHTML, arrAttachment);
            }
            protected override void Execute(CodeActivityContext context)
            {
                String sTO      = To.Get(context);
                String sBCC     = BCC.Get(context);
                String sCC      = CC.Get(context);
                String sAccount = Account.Get(context);
                String sBody    = Body.Get(context);
                String sSubject = Subject.Get(context);

                String[] arrAttachment           = Attachment.Get(context);
                Dictionary <String, String> dict = EmbedImage.Get(context);

                sendOutlookMailImage(sTO, sCC, sBCC, sBody, sSubject, sAccount, arrAttachment, dict);
            }
        protected override void Execute(CodeActivityContext context)
        {
            MailMessage forwardMail = MailMessage.Get(context);

            if (forwardMail != null)
            {
                string html = ExportMailToHtml(forwardMail);

                string strHeader = "<p>";

                string fMessage = ForwardMessage.Get(context);
                if (!string.IsNullOrEmpty(fMessage))
                {
                    fMessage = TextToHtml(fMessage);
                    Console.WriteLine(fMessage);
                    strHeader = fMessage + "<br>";
                }

                if (ShowOriginalMessage)
                {
                    strHeader  = strHeader + "<br><br>" + "-----Original Message-----" + "<br>";
                    strHeader += "From: " + forwardMail.From.DisplayName + "<br>";
                    strHeader += "Sent: " + forwardMail.Headers["Date"] + "<br>";
                    strHeader += "To: " + forwardMail.To + "<br>";
                    strHeader += "Subject: " + forwardMail.Subject + "<br><br>";
                }

                forwardMail.Subject    = "FW: " + forwardMail.Subject;
                forwardMail.IsBodyHtml = true;
                forwardMail.Body       = strHeader + GetTrimmedBodyText(html) + "</p>";

                string to = To.Get(context);
                if (!string.IsNullOrEmpty(to))
                {
                    to = to.Replace(",", ";");
                    var toSplits = to.Split(';');
                    foreach (var t in toSplits)
                    {
                        forwardMail.To.Add(new MailAddress(t));
                    }
                }

                string cc = CC.Get(context);
                if (!string.IsNullOrEmpty(cc))
                {
                    cc = cc.Replace(",", ";");
                    var ccSplits = cc.Split(';');
                    foreach (var cs in ccSplits)
                    {
                        forwardMail.CC.Add(new MailAddress(cs));
                    }
                }

                string bcc = BCC.Get(context);
                if (!string.IsNullOrEmpty(bcc))
                {
                    bcc = bcc.Replace(",", ";");
                    var bccSplits = bcc.Split(';');
                    foreach (var b in bccSplits)
                    {
                        forwardMail.Bcc.Add(new MailAddress(b));
                    }
                }

                this.ForwardMail.Set(context, forwardMail);
            }
            else
            {
                Console.WriteLine("No Mail Message Found");
            }
        }