Пример #1
0
        /// <summary>
        /// Files have been successfully transferred and we have a transmit token.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="transmitToken"></param>
        void TransmitDone(object sender, TransmitCompletedResult result)
        {
            // we might need to have this as a local variable
            Microsoft.Office.Interop.Outlook.Application applicationObject = this.Application;

            Microsoft.Office.Interop.Outlook.MailItem mailItem = null;
            try {
                object storeID = applicationObject.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderDrafts).StoreID;
                mailItem = (Microsoft.Office.Interop.Outlook.MailItem)applicationObject.Session.GetItemFromID(this.entryID, storeID);
                if (!string.IsNullOrEmpty(result.Response)) {
                    mailItem.Subject = SUBJECT_TRANSMITTED + mailItem.Subject;
                    if (mailItem.HTMLBody != null) {
                        string linkHtml = result.Response;

                        string str2 = "<img border=\"0\" width=\"120\" height=\"35\" src=\"cid:reply.gif\"/>";
                        int index = linkHtml.IndexOf(str2);
                        if (index > -1) {
                            linkHtml = linkHtml.Substring(0, index - 1) + linkHtml.Substring(index + str2.Length);
                        }
                        int length = -1;
                        length = mailItem.HTMLBody.ToUpper().LastIndexOf("</BODY>");
                        if (length != -1) {
                            mailItem.HTMLBody = mailItem.HTMLBody.Substring(0, length) + linkHtml + mailItem.HTMLBody.Substring(length, mailItem.HTMLBody.Length - length);
                        }
                        else {
                            mailItem.HTMLBody += "\n" + linkHtml;
                        }
                    }
                    else {
                        mailItem.Body = mailItem.Body + result.Response;
                    }

                    // do actual sending of email (move from Draft to Outbox)
                    (mailItem as Microsoft.Office.Interop.Outlook._MailItem).Send();
                }
                else {
                    mailItem.Display(false);
                    //this.RestoreFilesToSend(mailItem);
                    //this.RestoreFoldersToSend(mailItem);
                }
                try {
                    foreach (string str3 in this.filesToTransmit) {
                        File.Delete(str3);
                    }
                    if (this.filesToTransmit.Count > 0) {
                        new DirectoryInfo(Path.GetDirectoryName(this.filesToTransmit[0])).Delete();
                    }
                }
                catch (Exception exception) {
                    System.Windows.Forms.MessageBox.Show(exception.Message);
                    //MessageBox.Show(ForegroundWindow.Instance, Messages.Instance.Get("ErrorCleanup"), Messages.Instance.Get("MessageTitle"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //ErrorLogger.Log("ErrorCleanup", exception);
                }
            }
            catch (Exception exception2) {
                System.Windows.Forms.MessageBox.Show(exception2.Message);
                //MessageBox.Show(ForegroundWindow.Instance, Messages.Instance.Get("ErrorSending"), Messages.Instance.Get("MessageTitle"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                //ErrorLogger.Log("ErrorSending", exception2);
            }
            finally {
                if (mailItem != null) {
                    Marshal.ReleaseComObject(mailItem);
                }
                mailItem = null;
                if (applicationObject != null) {
                    Marshal.ReleaseComObject(applicationObject);
                }
                applicationObject = null;
                transferForm.Close();
                transferForm = null;
            }
        }
Пример #2
0
        /// <summary>
        /// 
        /// </summary>
        private void Transfer()
        {
            this.entryID = this.mailItem.EntryID;
            //this.addin.CloseInspector();
            options.Add("SenderMail", this.mailItem.SendUsingAccount.SmtpAddress ?? "Unknown");
            options.Add("Subject", this.mailItem.Subject ?? "");
            options.Add("Body", this.mailItem.Body);
            string[] strArray = new string[this.mailItem.Recipients.Count];
            for (int n = 0; n < this.mailItem.Recipients.Count; n++) {
                strArray[n] = this.mailItem.Recipients[n + 1].Address;
            }
            options.Add("Recipients", string.Join(";", strArray));

            transferForm = new TransferForm(filesToTransmit, options, this.TransmitDone);
            transferForm.StartTransfer();

            //Progress progress = new Progress(loginManager, this.completeFilesToSend, this.foldersToSend, parameters);
            //progress.Transport.OnBluewhaleDone += new Transport.BluewhaleDoneHandler(this.BluewhaleDoneHandler);
            //progress.Send();
        }