private void SendViaEmail(string dest, Outlook.MailItem email)
 {
     Outlook.MailItem newMail = Application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
     newMail = email.Forward();
     newMail.Recipients.Add(dest);
     newMail.Send();
 }
        public void ReceiveEmailAndForward()
        {
            // Create a simple mail
            Outlook.MailItem omail = Utilities.CreateSimpleEmail("CopyProperties");

            // Add a email attach for new created mail
            string attachDocument = ConfigurationManager.AppSettings["AttachDocument"].ToString();
            string fullPath       = Path.GetFullPath(attachDocument);

            Outlook.MailItem omailWithAttach = Utilities.AddAttachsToEmail(omail, new object[] { fullPath });

            // Send mail
            Utilities.SendEmail(omailWithAttach);

            // Get the latest send mail from send mail folder
            Outlook.MailItem omailReveived = Utilities.GetNewestItemInMAPIFolder(inboxFolders, "CopyProperties");
            omailReveived.Forward();

            // Parse the saved trace using MAPI Inspector
            List <string> allRopLists = new List <string>();
            bool          result      = MessageParser.ParseMessage(out allRopLists);

            // Update the XML file for the covered message
            Utilities.UpdateXMLFile(allRopLists);

            // Assert failed if the parsed result has error
            Assert.IsTrue(result, "Case failed, check the details information in error.txt file.");
        }
        /// <summary>
        /// 将request邮件转发到服务器邮箱,仅针对KR Team
        /// </summary>
        /// <param name="myItem"></param>
        private void ForwardMailItem(Outlook.MailItem myItem)
        {
            int importance = (int)myItem.Importance;

            Outlook.MailItem myForward = myItem.Forward();
            string           ag        = "OFR.GSCKRteam";
            //string sentNameMail = "*****@*****.**";//接收邮件的公邮地址
            string sentNameMail = "*****@*****.**";
            string iFlag        = "";

            switch (importance)
            {
            case 2:
                iFlag = "Country";
                break;

            case 1:
                iFlag = "Location";
                break;

            case 0:
                iFlag = "User(s)";
                break;
            }

            string        newLine     = System.Environment.NewLine;
            StringBuilder forwardBody = new StringBuilder();

            forwardBody.Append("Sender: ");
            forwardBody.Append(myItem.SenderEmailAddress);
            forwardBody.Append(newLine);
            forwardBody.Append("Assignment group: ");
            forwardBody.Append(ag);
            forwardBody.Append(newLine);
            forwardBody.Append("Impact:");
            forwardBody.Append(iFlag);
            forwardBody.Append(newLine);
            forwardBody.Append("Urgency: Normal");
            forwardBody.Append(newLine);
            forwardBody.Append("Impacted BU: DGF");
            forwardBody.Append(newLine);
            forwardBody.Append(newLine);
            forwardBody.Append(newLine);
            forwardBody.Append(newLine);
            forwardBody.Append("Original Message Below");
            forwardBody.Append(newLine);
            forwardBody.Append("_____________________________________________");
            forwardBody.Append(newLine);
            forwardBody.Append(newLine);
            forwardBody.Append(myForward.Body);
            myForward.Body = forwardBody.ToString();

            myForward.Recipients.Add(sentNameMail);
            myForward.Send();
        }
        // CopyProperties
        public void ReceiveEmailAndForward()
        {
            // Create a simple mail
            Outlook.MailItem omail = Utilities.CreateSimpleEmail("CopyProperties");
            // Add a email attach for new created mail
            string AttachDocument = ConfigurationManager.AppSettings["AttachDocument"].ToString();
            string fullPath       = Path.GetFullPath(AttachDocument);

            Outlook.MailItem omailWithAttach = Utilities.AddAttachsToEmail(omail, new object[] { fullPath });
            // Send mail
            Utilities.SendEmail(omailWithAttach);

            // Get the latest send mail from send mail folder
            Outlook.MailItem omailReveived = Utilities.GetNewestItemInMAPIFolder(inboxFolders, "CopyProperties");
            omailReveived.Body = omailReveived.Body + "Edited.";
            omailReveived.Save();
            omailReveived.Forward();

            bool result = MessageParser.ParseMessage();

            Assert.IsTrue(result, "Case failed, check the details information in error.txt file.");
        }
Esempio n. 5
0
 public static void ForwardMessage(Outlook.MailItem mailItem)
 {
     if (mailItem != null)
     {
         if (!Properties.Settings.Default.NoForwardConf)
         {
             DialogResult confirm = MessageBox.Show("Create Ticket?\nSubject: " + mailItem.Subject,
                                                    "Spiceworks Outlook AddIn", MessageBoxButtons.YesNo);
             if (confirm == DialogResult.Yes)
             {
                 string recipient = Properties.Settings.Default.HelpdeskEmail;
                 if (recipient == "" || recipient == null)
                 {
                     MessageBox.Show("Unable to forward message to Spiceworks. Please check that 'Helpdesk Email' is set in Settings."
                                     , "Spiceworks Outlook AddIn", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     try
                     {
                         Outlook.MailItem newMsg = mailItem.Forward();
                         newMsg.Subject = mailItem.Subject;
                         newMsg.Body   += "\n\n#created by " + Logic.GetSenderSMTPAddress(mailItem);
                         newMsg.Recipients.Add(recipient);
                         newMsg.Send();
                         if (Properties.Settings.Default.CloseMsg)
                         {
                             mailItem.Close(Outlook.OlInspectorClose.olPromptForSave);
                         }
                     }
                     catch
                     {
                         MessageBox.Show("Unable to forward message to Spiceworks. Please check that 'Helpdesk Email' is set in Settings."
                                         , "Spiceworks Outlook AddIn", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                 }
             }
         }
         else
         {
             string recipient = Properties.Settings.Default.HelpdeskEmail;
             if (recipient == "" || recipient == null)
             {
                 MessageBox.Show("Unable to forward message to Spiceworks. Please check that 'Helpdesk Email' is set in Settings."
                                 , "Spiceworks Outlook AddIn", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 try
                 {
                     Outlook.MailItem newMsg = mailItem.Forward();
                     newMsg.Subject = mailItem.Subject;
                     newMsg.Body   += "\n\n#created by " + Logic.GetSenderSMTPAddress(mailItem);
                     newMsg.Recipients.Add(recipient);
                     newMsg.Send();
                     if (Properties.Settings.Default.CloseMsg)
                     {
                         mailItem.Close(Outlook.OlInspectorClose.olPromptForSave);
                     }
                 }
                 catch
                 {
                     MessageBox.Show("Unable to forward message to Spiceworks. Please check that 'Helpdesk Email' is set in Settings."
                                     , "Spiceworks Outlook AddIn", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
     }
 }