コード例 #1
0
ファイル: Reutilizable.cs プロジェクト: cvalenciap/SYS_SGI
        public string ReenviarCorreo(ExchangeService exchange, EmailMessage message, List <AlertaSGIEntity> lstCorreo, string asuntoContinuar, string mensaje)
        {
            try
            {
                ResponseMessage responseMessage = message.CreateForward();

                if (asuntoContinuar != "")
                {
                    responseMessage.Subject = string.Format("{0} {1}", message.Subject, asuntoContinuar);
                }

                responseMessage.BodyPrefix = mensaje;

                //EmailAddress[] emailAddressCc = new EmailAddress[lstCorreoCc.Count];
                //EmailAddress[] emailAddressBcc = new EmailAddress[lstCorreoBcc.Count];

                //for (int i = 0; i < lstCorreoCc.Count; i++)
                //    emailAddressCc[i] = lstCorreoCc[i].CorreoElectronico;

                //for (int i = 0; i < lstCorreoBcc.Count; i++)
                //    emailAddressBcc[i] = lstCorreoBcc[i].CorreoElectronico;

                //responseMessage.ToRecipients.AddRange(emailAddressCc);
                //responseMessage.BccRecipients.AddRange(emailAddressBcc);
                responseMessage.SendAndSaveCopy();

                return("");
            }
            catch (Exception ex)
            {
                new Log().RegistrarEvento(Propiedades.Mensaje.CorreoErrorReenvio);
                return(ex.Message.ToString());
            }
        }
コード例 #2
0
ファイル: MessageForm.cs プロジェクト: kekici/EwsEditor
        private bool MakeResponseMessage(ResponseMessageType oResponseMessageType)
        {
            bool            bRet             = false;
            MessageBody     oMessageBody     = new MessageBody("----\r\n");
            ResponseMessage oResponseMessage = null;

            string sWindowTitle = string.Empty;

            try
            {
                if (oResponseMessageType == ResponseMessageType.Reply)
                {
                    _EmailMessage.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
                    oResponseMessage = _EmailMessage.CreateReply(false);
                    sWindowTitle     = "Reply Message";
                }
                if (oResponseMessageType == ResponseMessageType.ReplyAll)
                {
                    _EmailMessage.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
                    oResponseMessage = _EmailMessage.CreateReply(true);
                    sWindowTitle     = "Reply All Message";
                }
                if (oResponseMessageType == ResponseMessageType.Forward)
                {
                    _EmailMessage.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
                    oResponseMessage = _EmailMessage.CreateForward();
                    sWindowTitle     = "Forward Message";
                }

                //oResponseMessage.BodyPrefix = "===========\r\n";

                // Save as drafts AND set as new current message.
                _EmailMessage.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
                _EmailMessage = oResponseMessage.Save(WellKnownFolderName.Drafts);
                _EmailMessage.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
                _EmailMessage.Load();

                SetFormFromMessage(_EmailMessage, true, true, false);

                bRet = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error creating message");
                bRet = false;
            }
            return(bRet);
        }
コード例 #3
0
        private void forwardMessage(EmailMessage message)
        {
            ResponseMessage rMessage = message.CreateForward();

            // Setup Recipients
            if (Recipients != null)
            {
                foreach (string recipient in Recipients)
                {
                    rMessage.ToRecipients.Add(recipient);
                }
            }
            if (BCCRecipients != null)
            {
                foreach (string recipient in BCCRecipients)
                {
                    rMessage.BccRecipients.Add(recipient);
                }
            }
            if (CCRecipients != null)
            {
                foreach (string recipient in CCRecipients)
                {
                    rMessage.CcRecipients.Add(recipient);
                }
            }

            if (Subject != null)
            {
                rMessage.Subject = Subject;
            }
            if (Body != null)
            {
                MessageBody body = new MessageBody(bodyFormat, Body); rMessage.BodyPrefix = body;
            }

            if (RequestReadResponse.IsPresent)
            {
                rMessage.IsReadReceiptRequested = true;
            }
            if (RequestDeliveryReceipt.IsPresent)
            {
                rMessage.IsDeliveryReceiptRequested = true;
            }

            rMessage.SendAndSaveCopy();
        }
コード例 #4
0
ファイル: EmailHelper.cs プロジェクト: kg4mfq/RfiCoder
        public ResponseMessage CreateDraftEmail(EmailMessage originalEmail, Entity.Store store)
        {
            var forwardEmail = originalEmail.CreateForward();

            try {
                var contacts = connector.GetProjectContacts(store);

                foreach (var contact in contacts)
                {
                    forwardEmail.ToRecipients.Add(contact.Email);
                }
            } catch (ArgumentNullException ex) {
            }

            var body = @"Please see request for information below and respond as soon as possible.

PLEASE DO NOT MODIFY SUBJECT LINE
";

            forwardEmail.BodyPrefix = body;

            return(forwardEmail);
        }
コード例 #5
0
        /// <summary>
        /// Shared Mail logic for replying to a mail
        /// </summary>
        /// <param name="context"></param>
        protected override void Execute(CodeActivityContext context)
        {
            // ****************** getting the input values ************************
            ExchangeService objExchangeService = ObjExchangeService.Get(context);
            Item            mail           = Mail.Get(context);
            string          body           = Body.Get(context);
            bool            isBodyHTML     = IsBodyHTML.Get(context);
            string          recipientEmail = RecipientEmail.Get(context);
            string          cc             = Cc.Get(context);
            string          bcc            = Bcc.Get(context);
            string          sender         = Sender.Get(context);

            //******** Sending mail Logic ******
            EmailMessage    email          = EmailMessage.Bind(objExchangeService, mail.Id, new PropertySet(ItemSchema.Attachments));
            ResponseMessage forwardMessage = email.CreateForward();

            //Check for if body is a HTML content
            if (isBodyHTML)
            {
                forwardMessage.BodyPrefix = new MessageBody(BodyType.HTML, body);
            }
            else
            {
                forwardMessage.BodyPrefix = body;
            }

            //Adding recipients to mail
            string[] emails = recipientEmail.Split(';');
            foreach (string recipient in emails)
            {
                forwardMessage.ToRecipients.Add(recipient);
            }

            //Adding Cc to mail
            if (cc != null && cc.Length > 0)
            {
                string[] emailsCc = cc.Split(';');
                foreach (string recipient in emailsCc)
                {
                    forwardMessage.CcRecipients.Add(recipient);
                }
            }

            //Adding Bcc to mail
            if (bcc != null && bcc.Length > 0)
            {
                string[] emailsBcc = bcc.Split(';');
                foreach (string recipient in emailsBcc)
                {
                    forwardMessage.BccRecipients.Add(recipient);
                }
            }


            //Forwarding mail
            {
                FolderView view = new FolderView(10000);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.Traversal = FolderTraversal.Deep;
                Mailbox            mailbox           = new Mailbox(sender);
                FindFoldersResults findFolderResults = objExchangeService.FindFolders(new FolderId(WellKnownFolderName.MsgFolderRoot, mailbox), view);

                foreach (Folder folder in findFolderResults)
                {
                    if (folder.DisplayName == "Sent Items")
                    {
                        forwardMessage.SendAndSaveCopy(folder.Id);
                    }
                }
            }
        }
コード例 #6
0
        private GenResult EmailMessageFromMessage(
            StoredContact sender,
            StoredContact recipient,
            Storage.Message msg)
        {
            GenResult res = new GenResult();

            try
            {
                EmailAddress em =
                    Contact.Bind(this.service, new ItemId(sender.UniqId))
                    .EmailAddresses[EmailAddressKey.EmailAddress1];

                EmailMessage newMsg = new EmailMessage(this.service)
                {
                    From    = em,
                    Sender  = em,
                    Body    = new MessageBody(msg.BodyHtml),
                    Subject = msg.Subject
                };

                newMsg.Save(WellKnownFolderName.Drafts);

                foreach (object obj in msg.Attachments)
                {
                    Storage.Attachment attach = obj as Storage.Attachment;
                    if (attach == null)
                    {
                        continue;
                    }
                    newMsg.Attachments.AddFileAttachment(attach.FileName, attach.Data);
                }

                this.FillAdresses(ref newMsg, recipient.Email);

                res.msg = newMsg;

                // делаем ли форвард
                if (RndTrueFalse())
                {
                    newMsg.Update(ConflictResolutionMode.AlwaysOverwrite);
                    ResponseMessage respMsg = newMsg.CreateForward();
                    respMsg.BodyPrefix = @"test body prefix for forward message";
                    this.FillAdressesForResponse(ref respMsg, this.RndRecipMail());
                    respMsg.Save(WellKnownFolderName.Drafts);
                    res.response = respMsg;
                }

                // делаем ли реплай
                if (RndTrueFalse())
                {
                    /*newMsg.ReplyTo.Add(_RndRecipMail());
                     * if (_RndTrueFalse())
                     * {
                     *  newMsg.ReplyTo.Add(_RndRecipMail());
                     * }
                     *
                     * if (_RndTrueFalse()) */
                    {
                        newMsg.Update(ConflictResolutionMode.AlwaysOverwrite);
                        ResponseMessage replMsg = newMsg.CreateReply(RndTrueFalse());
                        replMsg.BodyPrefix = @"test body prefix for reply message";
                        this.FillAdressesForResponse(ref replMsg, recipient.Email);
                        replMsg.Save(WellKnownFolderName.Drafts);
                        res.reply = replMsg;
                    }
                }
            }
            catch (Exception exc)
            {
                GenericLogger <Generator> .Error(
                    LocalizibleStrings.ErrorCreateFromTemplate + msg.FileName, exc);
            }
            return(res);
        }