コード例 #1
0
ファイル: OutboxMonitor.cs プロジェクト: killbug2004/WSProf
        private static readonly object _lock = new object(); // Sync the processing of items in the Outbox

        public OutboxMonitor(Microsoft.Office.Interop.Outlook.Application application)
        {
            try
            {
                _application = application;
                _ns = _application.GetNamespace("MAPI");
                _outbox = _ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
                _items = _outbox.Items;
                _items.ItemAdd += Items_ItemAdd;

                SubmitNonDeferredItems();
                SyncroniseDeferredSendStore();
                CreateSubmitWorkerThreads();

				Logger.LogInfo("Secure File Transfer Outbox monitor created and configured.");
            }
            catch (Exception ex)
            {
                Dispose();

                Logger.LogError(ex);
                Logger.LogError("Failed to create OutboxMonitor. Disable DeferredSend");

                throw;
            }
        }
コード例 #2
0
ファイル: OutlookPortal.cs プロジェクト: mind0n/hive
		public OutlookPortal()
		{
			oApp = new Microsoft.Office.Interop.Outlook.Application();
			oNameSpace = oApp.GetNamespace("MAPI");
			oOutboxFolder = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
			oNameSpace.Logon(null, null, false, false);
			oMailItem =	(Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
			
		}
コード例 #3
0
 protected override void Initialize() {
     base.Initialize();
     this.Application = this.GetHostItem<Microsoft.Office.Interop.Outlook.Application>(typeof(Microsoft.Office.Interop.Outlook.Application), "Application");
     Globals.ThisAddIn = this;
     global::System.Windows.Forms.Application.EnableVisualStyles();
     this.InitializeCachedData();
     this.InitializeControls();
     this.InitializeComponents();
     this.InitializeData();
 }
コード例 #4
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));
            }
        }
コード例 #5
0
    public static void Kill(ref Microsoft.Office.Interop.Outlook.Application app)
    {
        long processId = 0;
        long appHwnd   = (long)app.Hwnd;

        GetWindowThreadProcessId(appHwnd, out processId);

        Process prc = Process.GetProcessById((int)processId);

        prc.Kill();
    }
コード例 #6
0
 private void CreateMailItem(string workItemNum)
 {
     Microsoft.Office.Interop.Outlook.Application app      = new Microsoft.Office.Interop.Outlook.Application();
     Microsoft.Office.Interop.Outlook.MailItem    mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
     mailItem.Subject = "Impact Analysis - New Item wad added: " + workItemNum;
     mailItem.To      = Settings.Default.MailRecipients;
     mailItem.Body    = "WorkItem number : " + workItem + " was added!";
     mailItem.Attachments.Add(Settings.Default.ImpactAnalysisExcelPath);
     mailItem.Display(false);
     mailItem.Send();
 }
コード例 #7
0
        //public void RunsThread(string User, string us, string pass, string Tids, string j, string name)
        public void RunsThread(string resort, string name)
        {
            //Use Office Interop to create email and pass the information into it
            Microsoft.Office.Interop.Outlook.Application oApp      = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook._MailItem   oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            oMailItem.HTMLBody = resort;
            DateTime dt = DateTime.Now;

            oMailItem.Subject = name + " " + String.Format("{0:d-MM-yyy}", dt);
            oMailItem.Display(false);
        }
コード例 #8
0
 protected override void Initialize()
 {
     base.Initialize();
     this.Application  = this.GetHostItem <Microsoft.Office.Interop.Outlook.Application>(typeof(Microsoft.Office.Interop.Outlook.Application), "Application");
     Globals.ThisAddIn = this;
     global::System.Windows.Forms.Application.EnableVisualStyles();
     this.InitializeCachedData();
     this.InitializeControls();
     this.InitializeComponents();
     this.InitializeData();
 }
コード例 #9
0
 private void Btn_Mail_Click(object sender, RoutedEventArgs e)
 {
     if (ToEdit.Email == null || ToEdit.Email == "")
     {
         MessageBox.Show("Er is geen mailadres bekend bij dit contactpersoon! Vul aub eerst een email adres in en druk op opslaan.");
         return;
     }
     Microsoft.Office.Interop.Outlook.Application oApp      = new Microsoft.Office.Interop.Outlook.Application();
     Microsoft.Office.Interop.Outlook._MailItem   oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
     oMailItem.To = ToEdit.Email;
     oMailItem.Display(true);
 }
コード例 #10
0
ファイル: Email.cs プロジェクト: iXombie/File-Notifier
        public void Send()
        {
            validate();
            buildMessage();

            var outlook          = new Microsoft.Office.Interop.Outlook.Application();
            var outlookNamespace = outlook.GetNamespace(NAMESPACE);

            outlookNamespace.Logon(Type.Missing, Type.Missing, true, true);

            mail.Send();
        }
コード例 #11
0
        public void Bilgi_Mail_Gonder(string vr_Subject, string vr_Klasör_Dizin)
        {
            Microsoft.Office.Interop.Outlook.Application OutlookObject = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    MailObject    = (Microsoft.Office.Interop.Outlook.MailItem)(OutlookObject.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem));
            MailObject.To         = "*****@*****.**";
            MailObject.CC         = "";
            MailObject.Subject    = "Merhaba, " + "#" + vr_Subject + "  " + tasinacakDosyaIsmi + "  İsimli Döküman Yayınlandı.";
            MailObject.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;
            //string htmlString = @"<html>
            //          <body>
            //          <p>Dear xxxx,</p>
            //          <p>It has been long since we...</p>
            //          <p>Sincerely,<br>Scott</br></p>
            //          </body>
            //          </html>
            //         ";
            string htmlString = $@"<html>
<head>
<meta http-equiv='Content-Language' content='tr'>
<meta http-equiv='Content-Type' content='text/html; charset=windows-1254'>
<title>Yeni Sayfa 1</title>
</head>
<body>
<form>
<br>
<br>
<br>
<table border='1' width='659' height='25' align='center'>
	<tr>
		<td height='25' width='659' colspan='2'><b>DÖKÜMAN EKLEME BİLGİSİ</b></td>
	</tr>
	<tr>
		<td height='25' width='330'><b>Döküman Uygulaması</b></td>
		<td height='25' width='329'>{vr_Subject}</td>
    </tr>
	<tr>
		<td height='25' width='330'><b>Döküman Adı</b></td>
		<td height='25' width='329'>{tasinacakDosyaIsmi}</td>
	</tr>
	<tr>
		<td height='25' width='330'><b>Döküman Yolu</b></td>
		<td height='25' width='329'>{vr_Klasör_Dizin}</td>
	</tr>
</table>
</Form>
</body>
</html>
                     ";

            MailObject.HTMLBody = htmlString;
            MailObject.Attachments.Add(tasinacakDosya, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1, "Ek Adı");
            MailObject.Send();
        }
コード例 #12
0
        private static void sendMailTemplate(StringBuilder mainBuilder, String mailSendTo, String mailSendCC, String mailSubject)
        {
            string HtmlFile = mainBuilder.ToString();

            Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            oMsg.To       = mailSendTo;
            oMsg.Subject  = mailSubject + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString();
            oMsg.HTMLBody = HtmlFile;
            oMsg.CC       = mailSendCC;
            oMsg.Send();
        }
コード例 #13
0
        async private void DoGenerateMail(object obj)
        {
            try
            {
                WorkInProgress = true;
                if (DeliveryBatch != null)
                {
                    var result = await RestHub.GenerateEmail(DeliveryBatch.Id);

                    if (result.HttpCode == System.Net.HttpStatusCode.OK)
                    {
                        try
                        {
                            Microsoft.Office.Interop.Outlook.Application oApp     = new Microsoft.Office.Interop.Outlook.Application();
                            Microsoft.Office.Interop.Outlook.MailItem    mailItem = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

                            mailItem.To         = "*****@*****.**";
                            mailItem.CC         = "[email protected];[email protected]";
                            mailItem.Subject    = "Reactions Mail";
                            mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
                            mailItem.HTMLBody   = result.UserObject.ToString();
                            mailItem.Display(false);
                        }
                        catch (Exception ex)
                        {
                            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{DeliveryBatch.BatchNumber}.html");
                            File.WriteAllText(path, result.UserObject.ToString());
                            AppInfoBox.ShowInfoMessage($"Unfortunately Outlook is not accessible. The prepared report will open in web browser, you may copy and paste in email manually.");
                            Process.Start(path);
                        }
                    }
                    else
                    {
                        AppErrorBox.ShowErrorMessage("Error While Generating Email . .", Environment.NewLine + result.HttpResponse);
                    }
                    DeliveryInProgress = Visibility.Hidden;
                }
                else
                {
                    MessageBox.Show("From Batch, From Category, Delivery Batch Number Is Required . . .");
                }
                WorkInProgress = false;
            }
            catch (Exception ex)
            {
                AppErrorBox.ShowErrorMessage("Can't generate mail report . .", ex.ToString());
            }
            finally
            {
                WorkInProgress = false;
            }
        }
コード例 #14
0
        /// <summary>
        /// Gets a list of all events in outlook
        /// </summary>
        public static List <CalendarEvent> GetAllEvents()
        {
            List <CalendarEvent> events = new List <CalendarEvent>();

            Microsoft.Office.Interop.Outlook.Application oApp                 = null;
            Microsoft.Office.Interop.Outlook.NameSpace   mapiNamespace        = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder  CalendarFolder       = null;
            Microsoft.Office.Interop.Outlook.Items       outlookCalendarItems = null;

            oApp           = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace  = oApp.GetNamespace("MAPI");
            CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;

            CalendarEvent cEvent = null;

            foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
            {
                cEvent = null;

                if (item.IsRecurring)
                {
                    Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
                    DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
                    DateTime last  = new DateTime(2008, 10, 1);
                    Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;

                    for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
                    {
                        try
                        {
                            recur  = rp.GetOccurrence(cur);
                            cEvent = new CalendarEvent(recur.GlobalAppointmentID, recur.Start, recur.End, recur.Location, recur.Subject, recur.Body);
                        }
                        catch
                        { }
                    }
                }
                else
                {
                    cEvent = new CalendarEvent(item.GlobalAppointmentID, item.Start, item.End, item.Location, item.Subject, item.Body);
                }

                if (cEvent != null)
                {
                    events.Add(cEvent);
                }
            }

            return(events);
        }
コード例 #15
0
        //method to send email to outlook
        private static void sendEMailThroughOUTLOOK(MailCommand mailCommand)
        {
            try
            {
                // Create the Outlook application.
                Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
                // Create a new mail item.
                Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                // Set HTMLBody.
                //add the body of the email
                if (mailCommand.Exception != null)
                {
                    oMsg.HTMLBody = "Error !!!" + Environment.NewLine + Environment.NewLine + mailCommand.Exception.Message;
                }
                else if (mailCommand.CommandType == CommandType.Exit | mailCommand.CommandType == CommandType.Hi | mailCommand.CommandType == CommandType.Stop | mailCommand.CommandType == CommandType.Start)
                {
                    oMsg.HTMLBody = mailCommand.Description;
                }
                else
                {
                    oMsg.HTMLBody = ConvertToHtmlFile(mailCommand);
                }

                //Add an attachment.
                //String sDisplayName = "MyAttachment";
                int iPosition = (int)oMsg.Body.Length + 1;
                //int iAttachType = (int)Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue;
                //now attached the file
                //Outlook.Attachment oAttach = oMsg.Attachments.Add(@"C:\\fileName.jpg", iAttachType, iPosition, sDisplayName);
                //Subject line
                oMsg.Subject = mailCommand.Command + " Executed (" + DateTime.Now.ToLongTimeString() + ")";
                // Add a recipient.
                Microsoft.Office.Interop.Outlook.Recipients oRecips = (Microsoft.Office.Interop.Outlook.Recipients)oMsg.Recipients;
                // Change the recipient in the next line if necessary.
                Microsoft.Office.Interop.Outlook.Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)oRecips.Add(mailCommand.ToAddress);
                oRecip.Resolve();
                // Send.
                oMsg.Send();
                // Clean up.
                oRecip  = null;
                oRecips = null;
                oMsg    = null;
                oApp    = null;

                Logger.Log(mailCommand.Command + " Result Send To " + mailCommand.ToAddress);
            }//end of try block
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
            } //end of catch
        }     //end of Email Method
        /// <summary>
        /// Gets a list of all events in outlook
        /// </summary>
        public static List<CalendarEvent> GetAllEvents()
        {
            List<CalendarEvent> events = new List<CalendarEvent>();

            Microsoft.Office.Interop.Outlook.Application oApp = null;
            Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null;
            Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null;

            oApp = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace = oApp.GetNamespace("MAPI");
            CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;

            CalendarEvent cEvent = null;

            foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
            {
                cEvent = null;

                if (item.IsRecurring)
                {
                    Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
                    DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
                    DateTime last = new DateTime(2008, 10, 1);
                    Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;

                    for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
                    {
                        try
                        {
                            recur = rp.GetOccurrence(cur);
                            cEvent = new CalendarEvent(recur.GlobalAppointmentID, recur.Start, recur.End, recur.Location, recur.Subject, recur.Body);
                        }
                        catch
                        { }
                    }
                }
                else
                {

                    cEvent = new CalendarEvent(item.GlobalAppointmentID, item.Start, item.End, item.Location, item.Subject, item.Body);
                }

                if (cEvent != null)
                    events.Add(cEvent);
            }

            return events;
        }
コード例 #17
0
 public void Initialize() {
     this.HostItemHost = ((Microsoft.VisualStudio.Tools.Applications.Runtime.IHostItemProvider)(this.RuntimeCallback.GetService(typeof(Microsoft.VisualStudio.Tools.Applications.Runtime.IHostItemProvider))));
     this.DataHost = ((Microsoft.VisualStudio.Tools.Applications.Runtime.ICachedDataProvider)(this.RuntimeCallback.GetService(typeof(Microsoft.VisualStudio.Tools.Applications.Runtime.ICachedDataProvider))));
     object hostObject = null;
     this.HostItemHost.GetHostObject("Microsoft.Office.Interop.Outlook.Application", "Application", out hostObject);
     this.Application = ((Microsoft.Office.Interop.Outlook.Application)(hostObject));
     Globals.ThisAddIn = this;
     System.Windows.Forms.Application.EnableVisualStyles();
     this.InitializeCachedData();
     this.InitializeControls();
     this.InitializeComponents();
     this.InitializeData();
     this.BeginInitialization();
 }
コード例 #18
0
 private void btnMail_Click(object sender, EventArgs e)
 {
     try
     {
         Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
         Microsoft.Office.Interop.Outlook._MailItem   mailItem   = outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
         mailItem.Subject = txtTicketNo.Text;
         mailItem.Display(true);
     }
     catch (Exception ex)
     {
         DisplayStatus("Unable to launch mail", StatusTypes.error);
     }
 }
コード例 #19
0
ファイル: Email.cs プロジェクト: iXombie/File-Notifier
        private void buildMessage()
        {
            var outlook = new Microsoft.Office.Interop.Outlook.Application();

            mail         = outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            mail.To      = ToAddresses;
            mail.CC      = CCAddresses;
            mail.BCC     = BCCAddresses;
            mail.Subject = Subject;
            mail.Body    = Body;
            if (Attachement != null)
            {
                mail.Attachments.Add(Attachement, Type.Missing, Type.Missing, Type.Missing);
            }
        }
コード例 #20
0
 static void Main(string[] args)
 {
     Microsoft.Office.Interop.Outlook.Application myApp         = new Microsoft.Office.Interop.Outlook.Application();
     Microsoft.Office.Interop.Outlook.NameSpace   mapiNameSpace = myApp.GetNamespace("MAPI");
     Microsoft.Office.Interop.Outlook.MAPIFolder  myContacts    = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
     mapiNameSpace.Logon(null, null, false, false);//"*****@*****.**""14March96kr#"
     mapiNameSpace.Logon(ConfigurationSettings.AppSettings["MailId"], ConfigurationSettings.AppSettings["Password"], Missing.Value, true);
     Microsoft.Office.Interop.Outlook.Items myItems = myContacts.Items;
     myInbox    = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
     destFolder = myInbox.Folders["MaliciousAttachments"];
     Microsoft.Office.Interop.Outlook.Items    inboxItems = myInbox.Items;
     Microsoft.Office.Interop.Outlook.Explorer myexp      = myInbox.GetExplorer(false);
     mapiNameSpace.Logon("Profile", Missing.Value, false, true);
     new Program().readingUnReadMailsAsync(inboxItems);
 }
コード例 #21
0
        private void ContainerDrop(object sender, DragEventArgs e)
        {
            f_DropText.Text = "";
            StringBuilder sb = new StringBuilder();

            foreach (string format in e.Data.GetFormats())
            {
                sb.AppendLine("Format:" + format);
                try
                {
                    object data = e.Data.GetData(format);
                    sb.AppendLine("Type:" + (data == null ? "[null]" : data.GetType().ToString()));
                    if (format == "FileGroupDescriptor")
                    {
                        Microsoft.Office.Interop.Outlook.Application OL = new Microsoft.Office.Interop.Outlook.Application();
                        sb.AppendLine("##################################################");
                        for (int i = 1; i <= OL.ActiveExplorer().Selection.Count; i++)
                        {
                            Object temp = OL.ActiveExplorer().Selection[i];
                            if (temp is Microsoft.Office.Interop.Outlook.MailItem)
                            {
                                Microsoft.Office.Interop.Outlook.MailItem mailitem = (temp as Microsoft.Office.Interop.Outlook.MailItem);
                                int n = 1;
                                sb.AppendLine("Mail " + i + ": " + mailitem.Subject);
                                foreach (Microsoft.Office.Interop.Outlook.Attachment attach in mailitem.Attachments)
                                {
                                    sb.AppendLine("File " + i + "." + n + ": " + attach.FileName);
                                    sb.AppendLine("Size " + i + "." + n + ": " + attach.Size);
                                    sb.AppendLine("For save using attach.SaveAsFile");
                                    ++n;
                                }
                            }
                        }
                        sb.AppendLine("##################################################");
                    }
                    else
                    {
                        sb.AppendLine("Data:" + data.ToString());
                    }
                }
                catch (Exception ex)
                {
                    sb.AppendLine("!!CRASH!! " + ex.Message);
                }
                sb.AppendLine("=====================================================");
            }
            f_DropText.Text = sb.ToString();
        }
コード例 #22
0
        public void Initialize()
        {
            this.HostItemHost = ((Microsoft.VisualStudio.Tools.Applications.Runtime.IHostItemProvider)(this.RuntimeCallback.GetService(typeof(Microsoft.VisualStudio.Tools.Applications.Runtime.IHostItemProvider))));
            this.DataHost     = ((Microsoft.VisualStudio.Tools.Applications.Runtime.ICachedDataProvider)(this.RuntimeCallback.GetService(typeof(Microsoft.VisualStudio.Tools.Applications.Runtime.ICachedDataProvider))));
            object hostObject = null;

            this.HostItemHost.GetHostObject("Microsoft.Office.Interop.Outlook.Application", "Application", out hostObject);
            this.Application     = ((Microsoft.Office.Interop.Outlook.Application)(hostObject));
            Globals.OutlookGnuPG = this;
            System.Windows.Forms.Application.EnableVisualStyles();
            this.InitializeCachedData();
            this.InitializeControls();
            this.InitializeComponents();
            this.InitializeData();
            this.BeginInitialization();
        }
コード例 #23
0
ファイル: UsersForm.cs プロジェクト: tmilanb/SH01Account
        public void CreateTemplate(User.UserAccount user)
        {
            Microsoft.Office.Interop.Outlook.Application newMail         = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook._MailItem   newMailTemplate = (Microsoft.Office.Interop.Outlook._MailItem)newMail.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            newMailTemplate.To      = user.Address;
            newMailTemplate.Subject = "New SH01 account";

            var sb = new StringBuilder();

            #region TemplateMail
            sb.AppendLine($"Dear {user.Name} ");
            sb.AppendLine(string.Empty);
            sb.AppendLine($@"The R&D Account SH01\{user.Account} has been created.");
            sb.AppendLine(string.Empty);
            sb.AppendLine("The new, TEMPORARY password is:");
            sb.AppendLine(string.Empty);
            sb.AppendLine(user.Password);
            sb.AppendLine(string.Empty);
            sb.AppendLine("Please use the self-service site below to change your password to something more personal right away:");
            sb.AppendLine(String.Format("https://SH01UserTools.onehc.net/SSAD"));
            sb.AppendLine(string.Empty);
            sb.AppendLine("Please be aware of the following:");
            sb.AppendLine(string.Empty);
            sb.AppendLine("Please note that the password reset tool does not accept blank characters.");
            sb.AppendLine("If you are using the wrong format, you will get the following error message: ");
            sb.AppendLine("’The account does not exist’");
            sb.AppendLine("For that reason, please use the following format of the account, when you paste it into the ’account’ field: ");
            sb.AppendLine(string.Empty);
            sb.AppendLine($@"SH01\{user.Account}");
            sb.AppendLine(string.Empty);
            sb.AppendLine("The password field is working the same as the account field. ");
            sb.AppendLine("Please always follow the instructions of the password reset tool!");
            sb.AppendLine("After the password change please wait at least 60 minutes for the synchronization to finish.");
            sb.AppendLine("If you use special characters in the password, please use only from the following ones: =#,.;:@!$%");
            sb.AppendLine("");
            sb.AppendLine("If you experience problems, you can also check the following link for help:");
            sb.AppendLine("Username was not found:");
            sb.AppendLine(String.Format("https://dev.azure.com/SHS-IT-AlmDev/Customer%20Information/_wiki/wikis/Customer-Information.wiki/109/Known-Issues?anchor=username-was-not-found-during-chaning-password-(sh01)"));
            sb.AppendLine(string.Empty);
            sb.AppendLine("If you have any further questions, please write into the ticket, as replies to this email are NOT PROCESSED.");
            #endregion

            newMailTemplate.Body = sb.ToString();

            newMailTemplate.Display(true);
        }
コード例 #24
0
        private void btnEmail_Click(object sender, EventArgs e)
        {
            try
            {
                Image bit = new Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);

                Graphics gs = Graphics.FromImage(bit);

                gs.CopyFromScreen(new Point(0, 0), new Point(0, 0), bit.Size);

                //bit.Save(@"C:\temp\temp.jpg");


                Rectangle bounds = this.Bounds;
                using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                {
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
                    }
                    bitmap.Save(@"C:\temp\temp.jpg");
                }


                Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.MailItem    mailItem   = outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                mailItem.Subject = "";
                mailItem.To      = "";
                string imageSrc = @"C:\Temp\temp.jpg"; // Change path as needed

                var attachments = mailItem.Attachments;
                var attachment  = attachments.Add(imageSrc);
                attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x370E001F", "image/jpeg");
                attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "myident"); // Image identifier found in the HTML code right after cid. Can be anything.
                mailItem.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8514000B", true);

                // Set body format to HTML

                mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
                mailItem.Attachments.Add(imageSrc);
                string msgHTMLBody = "";
                mailItem.HTMLBody = msgHTMLBody;
                mailItem.Display(true);
            }
            catch { }
        }
コード例 #25
0
ファイル: Form1.cs プロジェクト: guliv3r/MailSender
 public void SendMail()
 {
     try
     {
         Microsoft.Office.Interop.Outlook.Application app      = new Microsoft.Office.Interop.Outlook.Application();
         Microsoft.Office.Interop.Outlook.MailItem    mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
         mailItem.Subject    = $"ახალი თანამშრომელი {inp_fullname.Text.Trim()}";
         mailItem.To         = "*****@*****.**";
         mailItem.HTMLBody   = body;
         mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
         mailItem.Display(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #26
0
        }       // enviar email

        private void email_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.Office.Interop.Outlook.Application oApp      = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook._MailItem   oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                oMailItem.To = "meter campo transportadora.email";

                oMailItem.HTMLBody = "Segue em anexo o pdf com os dados da encomenda. <br> Atentamente, AMD";

                //Add an attachment.
                String sDisplayName = "Encomenda";
                int    iPosition    = (int)oMailItem.Body.Length + 1;
                int    iAttachType  = (int)Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue;

                //now attached the file
                Microsoft.Office.Interop.Outlook.Attachment oAttach = oMailItem.Attachments.Add(@"C:\\fileName.jpg", iAttachType, iPosition, sDisplayName);

                //Subject line
                oMailItem.Subject = "Encomenda AMD";

                // Add a recipient.
                Microsoft.Office.Interop.Outlook.Recipients oRecips = (Microsoft.Office.Interop.Outlook.Recipients)oMailItem.Recipients;

                // Change the recipient in the next line if necessary.
                Microsoft.Office.Interop.Outlook.Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)oRecips.Add("meter o campo da transportadora.email");
                oRecip.Resolve();

                oMailItem.Display(true);

                // Send.
                oMailItem.Send();

                // Clean up.
                oRecip    = null;
                oRecips   = null;
                oMailItem = null;
                oApp      = null;
            }


            catch (Exception ex)
            {
                MessageBox.Show("Não conseguimos carregar a aplicação de email. Por favor tente mais tarde.");
            }
        }
コード例 #27
0
ファイル: OutlookConn.cs プロジェクト: filipceglik/BadOutlook
        public static Microsoft.Office.Interop.Outlook.Application GetOutlookInstance()
        {
            Microsoft.Office.Interop.Outlook.Application ol = null;
            System.Diagnostics.Process[] processes          = System.Diagnostics.Process.GetProcessesByName("OUTLOOK");
            int collCount = processes.Length;

            if (collCount != 0)
            {
                ol = (Microsoft.Office.Interop.Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
            }
            else
            {
                ol = new Microsoft.Office.Interop.Outlook.Application();
            }

            return(ol);
        }
コード例 #28
0
        public override void RunCommand(object sender)
        {
            var vRecipients = v_Recipients.ConvertToUserVariable(sender);
            var vAttachment = v_Attachment.ConvertToUserVariable(sender);
            var vSubject    = v_Subject.ConvertToUserVariable(sender);
            var vBody       = v_Body.ConvertToUserVariable(sender);
            var vBodyType   = v_BodyType.ConvertToUserVariable(sender);

            var splittext = vRecipients.Split(';');

            Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();

            Microsoft.Office.Interop.Outlook.MailItem     mail        = (Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            Microsoft.Office.Interop.Outlook.AddressEntry currentUser =
                outlookApp.Session.CurrentUser.AddressEntry;
            if (currentUser.Type == "EX")
            {
                Microsoft.Office.Interop.Outlook.ExchangeUser manager =
                    currentUser.GetExchangeUser().GetExchangeUserManager();
                // Add recipient using display name, alias, or smtp address
                foreach (var t in splittext)
                {
                    mail.Recipients.Add(t.ToString());
                }

                mail.Recipients.ResolveAll();

                mail.Subject = vSubject;

                if (vBodyType == "HTML")
                {
                    mail.HTMLBody = vBody;
                }
                else
                {
                    mail.Body = vBody;
                }

                if (!string.IsNullOrEmpty(vAttachment))
                {
                    mail.Attachments.Add(vAttachment);
                }

                mail.Send();
            }
        }
コード例 #29
0
        public UnitTestNewStyleConfirm()
        {
            string fileName = "./NewStyleConfirm.txt";

            if (!File.Exists(fileName))
            {
                Assert.Fail(fileName + " not found");
                return;
            }

            StreamReader sr = File.OpenText(fileName);

            content = sr.ReadToEnd();

            app            = new Microsoft.Office.Interop.Outlook.Application();
            emailProcessor = new EmailProcessorSpoteryII(app);
            //
        }
コード例 #30
0
ファイル: Default.aspx.cs プロジェクト: javitolin/MeetApp
        protected void outlookButton_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Outlook.Application oApp                 = null;
            Microsoft.Office.Interop.Outlook.NameSpace   mapiNamespace        = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder  CalendarFolder       = null;
            Microsoft.Office.Interop.Outlook.Items       outlookCalendarItems = null;

            oApp                 = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace        = oApp.GetNamespace("MAPI");;
            CalendarFolder       = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
            outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;
            allCalendarItemsText.Text = "";
            foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
            {
                allCalendarItemsText.Text += item.Subject + " -> " + item.Start.ToLongDateString();
            }
        }
コード例 #31
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Outlook.Application myApp         = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.NameSpace   mapiNameSpace = myApp.GetNamespace("MAPI");
            Microsoft.Office.Interop.Outlook.MAPIFolder  myInbox       = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

            Microsoft.Office.Interop.Outlook.MAPIFolder oPublicFolder = myInbox.Parent;

            cmbOutlookFolders.Items.Clear();

            foreach (Microsoft.Office.Interop.Outlook.MAPIFolder folder in oPublicFolder.Folders)
            {
                EnumerateFolders(folder);
            }

            cmbOutlookFolders.DisplayMember = "Value";
            cmbOutlookFolders.ValueMember   = "Key";
        }
コード例 #32
0
ファイル: main.cs プロジェクト: staherianYMCA/test
        public static void GetAllTaskItems()
        {
            Microsoft.Office.Interop.Outlook.Application oApp                 = null;
            Microsoft.Office.Interop.Outlook.NameSpace   mapiNamespace        = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder  CalendarFolder       = null;
            Microsoft.Office.Interop.Outlook.Items       outlookCalendarItems = null;

            oApp          = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace = oApp.GetNamespace("MAPI");
            ;
            CalendarFolder =
                mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderTasks);
            outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;

            foreach (Microsoft.Office.Interop.Outlook.TaskItem item in outlookCalendarItems)
            {
                if (item.IsRecurring)
                {
                    //Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
                    //DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
                    //DateTime last = new DateTime(2008, 10, 1);
                    //Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;



                    //for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
                    //{
                    //    try
                    //    {
                    //        recur = rp.GetOccurrence(cur);
                    //        Console.WriteLine(recur.Subject + " -> " + cur.ToLongDateString());
                    //    }
                    //    catch
                    //    {
                    //    }
                    //}
                }
                else
                {
                    Console.WriteLine(item.Subject + " -> " /* + item.Start.ToLongDateString()*/);
                }
            }
        }
コード例 #33
0
        private void SendMessage(Microsoft.Office.Interop.Outlook.Application oApp, List <string> bodyMessage, string stringBodyMessage, string receiver, string subject, string from, string to)
        {
            try
            {
                // Create a new mail item. Pass the application received on the form as parameter
                Microsoft.Office.Interop.Outlook.MailItem oMsg = (Microsoft.Office.Interop.Outlook.MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

                //add the body of the email
                oMsg.HTMLBody = stringBodyMessage;
                //Add an attachment.
                String sDisplayName = "MyAttachment";
                int    iPosition    = (int)oMsg.Body.Length + 1;
                int    iAttachType  = (int)Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue;
                //now attached the file
                prepareMessage(bodyMessage, from, to);
                //clearFieldsAndClose();

                string thePath = Path.Combine
                                     (AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "picture1.png");
                Microsoft.Office.Interop.Outlook.Attachment oAttach =
                    oMsg.Attachments.Add(thePath, iAttachType, iPosition, sDisplayName);

                //Subject line
                oMsg.Subject = subject;
                // Add a recipient.
                Microsoft.Office.Interop.Outlook.Recipients oRecips =
                    (Microsoft.Office.Interop.Outlook.Recipients)oMsg.Recipients;
                // Change the recipient in the next line if necessary.
                Microsoft.Office.Interop.Outlook.Recipient oRecip =
                    (Microsoft.Office.Interop.Outlook.Recipient)oRecips.Add(receiver);
                oRecip.Resolve();
                // Send.
                oMsg.Send();
                // Clean up.
                oRecip  = null;
                oRecips = null;
                oMsg    = null;
                oApp    = null;
            }//end of try block
            catch (System.Exception ex)
            {
                MessageBox.Show("An error occurs. " + ex.Message);
            }//end of catch
        }
コード例 #34
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var selectedContact = list_Contacts.SelectedItem as Contact;

            if (selectedContact == null)
            {
                MessageBox.Show("Selecteer eerst een contact aub.");
                return;
            }
            if (selectedContact.Email == null || selectedContact.Email == "")
            {
                MessageBox.Show("Er is geen mailadres bekend bij dit contactpersoon!");
                return;
            }
            Microsoft.Office.Interop.Outlook.Application oApp      = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook._MailItem   oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            oMailItem.To = selectedContact.Email;
            oMailItem.Display(true);
        }
コード例 #35
0
        public Calendar(int Days, List<String> EMails, String path, String ID)
        {
            sendEmail = false;
            objEntryID = ID;
            _Days = Days;
            _EMails = EMails;
            EmailEvents = new List<EmailEvent>();

            // set log path from logPath constant from Main()
            LOGPATH = path;
#if Debug
            try
            {
#endif
               
                objOutlook = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.NameSpace objNS = objOutlook.GetNamespace("MAPI");


                //objEntryID = "000000005BCDA19FC3AF564C9A7D910BCCF3D24642820000";
                //String objEntryID = "00000000E6BD34CD1C0FA04DBA1773A312FE25690100E15948BC84BC624E822DC6493E0F48BE0010CCEC4D970000";
                
                objCalendar = objOutlook.Session.GetFolderFromID(objEntryID, System.Type.Missing);    
            

               
#if Debug

            }
            catch (Exception ex)
            {
                //ToDo:
                // add handling for exception accessing Outlook
                System.IO.File.AppendAllText(LOGPATH,DateTime.Now.ToString() + ": " + ex.Message + Environment.NewLine);
                return;
            }
#endif

            findEvents();
            


        }
コード例 #36
0
        public void PlanThreads(string name, string resort)
        //public void PlanThreads(string User, string us, string pass, string j, string name, string[] runs)
        {
            //Use Office Interop to create email and pass the information into it
            Microsoft.Office.Interop.Outlook.Application oApp      = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook._MailItem   oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
            //table is passed to the body of the email
            oMailItem.HTMLBody = resort;
            //date is set
            DateTime dt = DateTime.Now;

            //subject of the email
            oMailItem.Subject = name + " " + String.Format("{0:d-MM-yyy}", dt);
            //
            oMailItem.Display(false);

            //DataTable table = new DataTable;
            //table.Initialized
        }
コード例 #37
0
ファイル: parser.cs プロジェクト: twreid/PracticumEmailer
        public Parser(string file, bool? test, IEmailManager emailManager,
            IStudentManager studentManager)
        {
            try
            {
                _excelFactory = new ExcelQueryFactory(file);
            }
            catch (IOException e)
            {
                throw;
            }

            _emailManager = emailManager;
            _studentManager = studentManager;
            _students = new Dictionary<string, Domain.Student>();
            _myOutlook = new Application();
            _isTest = test;

            _studentTask = Task.Factory.StartNew(PopulateStudents);
        }
コード例 #38
0
ファイル: OutlookMail.cs プロジェクト: manivts/impexcubeapp
        /// <summary>
        /// Constructor
        /// </summary>
        public OutlookMail()
        {
            //Return a reference to the MAPI layer
              oApp = new Microsoft.Office.Interop.Outlook.Application();
              oNameSpace= oApp.GetNamespace("MAPI");

              /***********************************************************************
              * Logs on the user
              * Profile: Set to null if using the currently logged on user, or set
              *    to an empty string ("") if you wish to use the default Outlook Profile.
              * Password: Set to null if  using the currently logged on user, or set
              *    to an empty string ("") if you wish to use the default Outlook Profile
              *    password.
              * ShowDialog: Set to True to display the Outlook Profile dialog box.
              * NewSession: Set to True to start a new session. Set to False to
              *    use the current session.
              ***********************************************************************/
              oNameSpace.Logon(null,null,true,true);

              //gets defaultfolder for my Outlook Outbox
              oSentItems = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);
        }
コード例 #39
0
        public List<outlookProperty> GetContent(DateTime DateFrom, DateTime DateTo)
        {
            string strContent="";
            string strSubject="";
            DateTime MailDate;
            //string strFrom;
            string strTo="";
            List<outlookProperty> result = new List<outlookProperty>();
            var app = new Microsoft.Office.Interop.Outlook.Application();
            var nameSpace = app.GetNamespace("MAPI");
            var inboxFolder = nameSpace.Folders["*****@*****.**"].Folders["Inbox"].Folders["MEC"];
            int intTopiterator = inboxFolder.Items.Count;
            var mailItems = inboxFolder.Items;
            //foreach (Microsoft.Office.Interop.Outlook.MailItem mailItem in inboxFolder.Items)
            for (int i = 1; i <= intTopiterator;i++ )
            {
                //strTo = mailItems[1];
                strSubject = mailItems[i].Subject.ToString();
                strContent = mailItems[i].Body.ToString();
                MailDate = mailItems[i].CreationTime.Date;
                //strFrom=mailItem.f
                //if (mailItem.To.ToString() != null)
                //{
                //    strTo = mailItem.To.ToString();
                //}
                //else
                //{
                //    strTo = "";
                //}

                if (MailDate >= DateFrom && MailDate <= DateTo)
                {
                    result.Add(new outlookProperty() { strSubject = strSubject, strContent = strContent, CreationDate = MailDate, strFrom = "", strTo = "" });
                }

            }
            return result;
        }
コード例 #40
0
        public static void OpenOutlookMail(string outlookLink)
        {
            outlookLink = outlookLink.Substring(8);

            try
            {

                Microsoft.Office.Interop.Outlook.Application app;
                Microsoft.Office.Interop.Outlook._NameSpace ns;

                app = new Microsoft.Office.Interop.Outlook.Application();
                ns = app.GetNamespace("MAPI");
                ns.Logon(null, null, false, false);

                Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem)
                    ns.GetItemFromID(outlookLink);
                mailItem.Display();
            }
            catch (Exception ex)
            {

            }
        }
        public void read()
        {
            Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.NameSpace ns = outlook.GetNamespace("Mapi");
            object _missing = Type.Missing;
            ns.Logon(_missing, _missing, false, true);
            Microsoft.Office.Interop.Outlook.MAPIFolder inbox = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
            string foldername = inbox.Name;
            int iMailCount = inbox.Items.Count;
            TraceService("Inside read method");

            for(int iCount =1 ;iCount <= iMailCount;iCount++)
            {
                Object mail1 = inbox.Items[iCount];
                if (((mail1 as Microsoft.Office.Interop.Outlook.MailItem) != null) && ((mail1 as Microsoft.Office.Interop.Outlook.MailItem).UnRead == true))
                {
                    TraceService("Inside unread mail");
                    Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)inbox.Items[iCount];
                    SqlConnection con;
                    string connection = @"server=CSM-DEV\SQL2008;database=TerexBest;uid=sa;pwd=rimc@123";
                    TraceService("Connection with database done1");
                    con = new SqlConnection(connection);
                    SqlCommand cmd;
                    cmd = new SqlCommand();
                    con.Open();

                    cmd.Connection = con;
                    TraceService("Connection assigned to sql command");

                    string subject = mail.Subject.ToString();
                    TraceService("mail subject written"+subject);
                    string body = mail.Body.ToString();
                    cmd.Parameters.Add("@subject", SqlDbType.NVarChar).Value = subject;

                    TraceService(subject); //writing subject

                    cmd.Parameters.Add("@body", SqlDbType.NVarChar).Value = body;

                    TraceService(body); //writing subject

                    cmd.Parameters.Add("@recievedtime", SqlDbType.DateTime).Value = mail.ReceivedTime;

                    TraceService(mail.ReceivedTime.ToString()); //writing subject

                    cmd.Parameters.Add("@mailfrom", SqlDbType.NVarChar).Value = mail.SenderEmailAddress;

                    TraceService(mail.SenderEmailAddress); //writing subject
                    TraceService("Before Inventory saved");

                    cmd.CommandText = "insert into storemail(subject,body,createddatetime,mailfrom,isActive) values(@subject,@body,@recievedtime,@mailfrom,1)";
                    TraceService("Inventory saved");
                    try
                    {
                        cmd.ExecuteNonQuery();
                        mail.Delete();
                        iMailCount = iMailCount - 1;
                    }
                    catch (SqlException ex)
                    {
                        ex.ToString();
                    }
                        con.Close();
                        cmd.Dispose();
                        con.Dispose();

               }
            }

            GC.Collect();
            inbox = null;
            ns = null;
            outlook = null;
        }
コード例 #42
0
    protected void OnButtonInvoiceEmailSelectionClicked(object sender, EventArgs e)
    {
        GridItemCollection col = gridInvoice.SelectedItems;
        IList<Invoices> invoiceList = new List<Invoices>();
        string email = string.Empty;
        foreach (GridDataItem item in col)
        {
            TableCell cell = item["InvoiceIdPK"];
            if (!string.IsNullOrEmpty(cell.Text))
            {
                string[] key = cell.Text.Split('-');
                int idFactNumber = int.Parse(key[0]);
                string type = key[1];
                int idYear = int.Parse(key[2]);
                Invoices invoice = new InvoicesRepository().GetInvoiceByID(idFactNumber, type, idYear);
                invoiceList.Add(invoice);
                CompanyAddress address = new CompanyAddressRepository().FindOne(
                    new CompanyAddress(invoice.RefCustomerNumber.Value));

                if (!string.IsNullOrEmpty(address.Email))
                {
                    if (email == string.Empty)
                    {
                        email = address.Email.Trim();
                    }
                    else if (email != address.Email.Trim())
                    {
                        string message = ResourceManager.GetString("messageInvoicesNotHaveSameEmail");
                        string script1 = "<script type=\"text/javascript\">";
                        script1 += " alert(\"" + message + "\")";
                        script1 += " </script>";

                        if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                            ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
                        return;
                    }
                }
                else
                {
                    string message = ResourceManager.GetString("messageInvoiceNotHaveAnyEmail");
                    string script1 = "<script type=\"text/javascript\">";
                    script1 += " alert(\"" + message + "\")";
                    script1 += " </script>";

                    if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                        ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
                    return;
                }
            }
        }

        Microsoft.Office.Interop.Outlook.Application outlookApp =
                        new Microsoft.Office.Interop.Outlook.Application();
        Microsoft.Office.Interop.Outlook.MailItem mailItem =
            (Microsoft.Office.Interop.Outlook.MailItem)
            outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
        mailItem.To = email;
        mailItem.Subject = "Send invoice";

        foreach (Invoices item in invoiceList)
        {
            string fileName = Common.ExportInvoices(
                item, WebConfig.AddressFillInInvoice, WebConfig.AbsoluteExportDirectory);
            mailItem.Attachments.Add(fileName,
                Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, Type.Missing, Type.Missing);
        }
        mailItem.Display(true);
    }
コード例 #43
0
        private static Microsoft.Office.Interop.Outlook.Application GetApplicationObject()
        {
            Microsoft.Office.Interop.Outlook.Application application = null;

            // Check whether there is an Outlook process running.
            if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
            {

                // If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
                application = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
            }
            else
            {

                // If not, create a new instance of Outlook and log on to the default profile.
                application = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
                nameSpace.Logon("yahara\test", "test1234", System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                //nameSpace = null;
            }

            // Return the Outlook Application object.
            return application;
        }
コード例 #44
0
        internal static Status DoWork(DateTime date, bool reallyDoWork = false)
        {
            try
            {

                if (reallyDoWork == false) //avoid contacting outlook server in this case
                {
                    var s = (from l in ListStatus
                             where l.Date == date.DateTimeToString()
                             select l).FirstOrDefault();

                    if (s != null)
                    {
                        return s;
                    }
                    else
                    {
                        return new Status(date);
                    }
                }

                lock (_doOutlookWorkSync)
                {
                    Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
                    Microsoft.Office.Interop.Outlook.NameSpace objNsp = objApp.GetNamespace("MAPI");
                    //objNsp.Logon("yahara\test", "test1234", false, true);
                    //Microsoft.Office.Interop.Outlook.Application objApp = GetApplicationObject();
                    //Microsoft.Office.Interop.Outlook.NameSpace objNsp = objApp.GetNamespace("MAPI");

                    Status s1 = null;
                    Status s2 = null;

                    Status final = null;

                    //mail
                    Microsoft.Office.Interop.Outlook.MAPIFolder objMAPIFolder = objNsp.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

                    // Set recepient
                    Microsoft.Office.Interop.Outlook.Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)objNsp.CreateRecipient("*****@*****.**");

                    // Get calendar folder
                    Microsoft.Office.Interop.Outlook.MAPIFolder calendarFolder = objNsp.GetSharedDefaultFolder(oRecip, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

                    if (ListStatus == null || ListStatus.Count == 0) // first call
                    {
                        ListStatus = new List<Status>(NumberOfPastDaysToCache + NumberOfFutureDaysToCache);

                        for (int i = -1 * NumberOfFutureDaysToCache; i < NumberOfPastDaysToCache + NumberOfFutureDaysToCache; i++)
                        {
                            DateTime specificDate = date.AddDays(-1 * i);
                            Debug.WriteLine("i=" + i.ToString() + " & specificDate=" + specificDate.DateTimeToString());
                            try
                            {
                                s1 = DownloadStatusForDate(specificDate, objMAPIFolder);
                                s2 = DownloadMeetingsForDate(specificDate, calendarFolder);
                                final = new Status(s1.Date.StringToDateTime());
                                if (s1 != null && s1.ListOfItems != null && s1.ListOfItems.Count > 0)
                                    final.ListOfItems.AddRange(s1.ListOfItems);
                                if (s2 != null && s2.ListOfItems != null && s2.ListOfItems.Count > 0)
                                    final.ListOfItems.AddRange(s2.ListOfItems);
                                ListStatus.Add(final);
                            }
                            catch
                            {
                                ListStatus.Add(new Status(specificDate));
                                ;//swallow and move on
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            s1 = DownloadStatusForDate(DateTime.Today, objMAPIFolder);
                            s2 = DownloadMeetingsForDate(DateTime.Today, calendarFolder);
                            final = new Status(s1.Date.StringToDateTime());
                            if (s1 != null && s1.ListOfItems != null && s1.ListOfItems.Count > 0)
                                final.ListOfItems.AddRange(s1.ListOfItems);
                            if (s2 != null && s2.ListOfItems != null && s2.ListOfItems.Count > 0)
                                final.ListOfItems.AddRange(s2.ListOfItems);

                            //find and remove stale entry
                            var s = (from l in ListStatus
                                     where l.Date == DateTime.Today.DateTimeToString()
                                     select l).FirstOrDefault();
                            if (s != null)
                                ListStatus.Remove(s);

                            //add fresh entry
                            ListStatus.Add(final);
                        }
                        catch
                        {
                            ;//swallow and move on
                        }
                    }

                    if (calendarFolder != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(calendarFolder);
                        calendarFolder = null;
                    }

                    if (oRecip != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(oRecip);
                        oRecip = null;
                    }

                    if (objMAPIFolder != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objMAPIFolder);
                        objMAPIFolder = null;
                    }

                    objApp.Session.Logoff();
                    if (objApp.Session != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objApp.Session);
                    }

                    if (objNsp != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objNsp);
                        objNsp = null;
                    }

                    (objApp as Microsoft.Office.Interop.Outlook._Application).Quit();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    if (objApp != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objApp);
                        objApp = null;
                    }
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    var st = (from l in ListStatus
                              where l.Date == date.DateTimeToString()
                              select l).FirstOrDefault();
                    return st;
                }
            }
            catch (Exception e)
            {
                EventLog.WriteEntry(sSource, "Exception in YaharaEmployeeStatusService" + Environment.NewLine + "Message = " + e.Message
                    + Environment.NewLine + "StackTrace" + Environment.NewLine + e.StackTrace
                    , EventLogEntryType.Error, 234);
                return new Status(date);
                ;//Exception swallowing technology at work here
            }
        }
コード例 #45
0
 private bool sendMessage(string from, string to, string subject, string content)
 {
     try
     {
         Microsoft.Office.Interop.Outlook.Application outlook =
             new Microsoft.Office.Interop.Outlook.Application();
         Microsoft.Office.Interop.Outlook.MailItem mailItem =
             (Microsoft.Office.Interop.Outlook.MailItem)
             outlook.CreateItem(Microsoft.Office.Interop.Outlook
             .OlItemType.olMailItem);
         mailItem.Subject = subject;
         mailItem.To = to;
         mailItem.HTMLBody = content;
         mailItem.Importance = important ?
             Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh
             : Microsoft.Office.Interop.Outlook.OlImportance.olImportanceNormal;
         mailItem.BodyFormat = Microsoft.Office.Interop.Outlook
             .OlBodyFormat.olFormatHTML;
         mailItem.Display(false);
         mailItem.Send();
         return true;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
コード例 #46
0
      private void timer_CntDwn_Tick(object sender, EventArgs e)
      {
         if ((cntDown < 55) && (subContent.Length == 0))
         {
            this.richTextBox1.Text = String.Format("No data to send at {0} (cancelled)", DateTime.Now.ToString());
            this.timer_CntDwn.Enabled = false;
            File.WriteAllText(tmpFile, subContent); // avoid a re-trigger in 5 minutes.
         }
         else if (cntDown > 0)
         {
            this.richTextBox1.Text = String.Format("Sending in {0} seconds:\n{1}", cntDown, subContent);
            cntDown--;
            switch (cntDown)
            {
               case 59:
                  //case 54:
                  //case 44:
                  this.Show();
                  this.WindowState = FormWindowState.Normal;
                  this.TopMost = true;
                  this.CenterToScreen();
                  this.TopMost = false;
                  break;
            }
         }
         else
         {
            this.richTextBox1.Text = String.Format("Sent at {0}:\n{1}", DateTime.Now.ToString(), subContent);
            string emailTo = this.textBox_eMail.Text;
            string originalValue = MyKepiCrawler.Properties.Settings.Default.Properties["MySendEmail"].DefaultValue as string;
            if (emailTo == originalValue)
               emailTo = "";
            try
            {
               File.WriteAllText(tmpFile, subContent);

               if (emailTo.Length > 3)
               {
                  string bodyEmail = subContent;

                  Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
                  Microsoft.Office.Interop.Outlook.MailItem eMail = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

                  eMail.Subject = "Kepi Update V1";
                  eMail.To = emailTo;
                  eMail.Body = bodyEmail;
                  ((Microsoft.Office.Interop.Outlook._MailItem)eMail).Send();
               }
            }
            catch (Exception ex)
            {
               string errMsg = String.Format("Error sending 'Kepi Update' Email: {0} at {1}:\n{2}", ex.Message, DateTime.Now.ToString(), subContent);
               this.richTextBox1.Text = errMsg;
               File.WriteAllText(tmpFile, errMsg);
            }
            finally
            {
               this.timer_CntDwn.Enabled = false;
            }
         }
         Properties.Settings.Default.MySearchString = this.textBox2.Text;
         Properties.Settings.Default.MySendEmail = this.textBox_eMail.Text;
         Properties.Settings.Default.Save();
      }
コード例 #47
0
ファイル: MyWork.cs プロジェクト: azarkevich/TortoiseRally
        void buttonGenerate_Click(object sender, EventArgs e)
        {
            UsageMetrics.IncrementUsage(UsageMetrics.UsageKind.DailyReportClickGenerate);
            var selectedArtifacts = listViewChanged.SelectedItems
                .Cast<ListViewItem>()
                .Select(lvi => lvi.Tag as ChangedArtifact)
                .Select(change => new { Artifact = new Artifact(change.Artifact), Change = change, RawArtifact = change.Artifact })
                .ToList()
            ;

            var groupedArtifacts = selectedArtifacts
                .GroupBy(a => {
                    if (a.Artifact.Parent != null && a.Artifact.Parent.Type == ArtifactType.Defect)
                    {
                        if (a.Artifact.Parent.Parent == null)
                            return null;

                        return a.Artifact.Parent.Parent.Name;
                    }

                    if (a.Artifact.Parent == null)
                        return null;

                    return a.Artifact.Parent.Name;
                })
                .ToArray()
            ;

            var sb = new StringBuilder();

            sb.AppendLine(@"<head><style>
            td, th {
            border: 1px solid black;
            padding: 3px;
            }
            table {
            border-collapse: collapse;
            table-layout: fixed;
            }
            .parent-col {
            width: 200px;
            }
            td.parent-col {
            font-size: 70%;
            color: #B8B894
            }
            .task-col {
            }
            .state-col {
            width: 100px;
            }
            td.state-col {
            font-size: 70%;
            width: 100px;
            }
            .notes-col {
            width: 400px;
            }
            </style></head>
            ");

            sb.AppendLine("<TABLE border=1>");
            sb.AppendLine("<tr>");
            sb.AppendLine("<th class='parent-col'>Parent (US/DE)</th>");
            sb.AppendLine("<th class='task-col'>Task / Defect</th>");
            sb.AppendLine("<th class='state-col'>State</th>");
            sb.AppendLine("<th class='notes-col'>Notes</th>");
            sb.AppendLine("</tr>");

            foreach (var group in groupedArtifacts)
            {
                sb.AppendLine("<tr>");
                sb.AppendFormat("<td class='parent-col' rowspan='{0}' style='word-wrap: break-word'>", group.Count());

                var groupArtifact = group.First().Change.WorkItem.Parent;
                if (groupArtifact.Parent != null && groupArtifact.Parent.Type == ArtifactType.Defect)
                    groupArtifact = groupArtifact.Parent;

                sb.AppendFormat("<a href='{0}'>{1}</a>: {2}</td>",
                    HttpUtility.UrlEncode(groupArtifact.Url),
                    groupArtifact.FormattedID,
                    HttpUtility.HtmlEncode(groupArtifact.Name)
                );

                sb.AppendFormat("</td>");
                var addTr = false;
                foreach (var change in group)
                {
                    var artifact = change.Artifact;

                    if (addTr)
                    {
                        sb.AppendLine("<tr>");
                    }
                    sb.AppendLine("<td class='task-col'>");
                    sb.AppendFormat("<a href='{0}'>{1}</a>: {2}", artifact.Url, artifact.FormattedID, HttpUtility.HtmlEncode(artifact.Name));
                    sb.AppendLine();
                    if (artifact.Parent != null && artifact.Parent.Type == ArtifactType.Defect)
                    {
                        sb.AppendLine("<br/>");
                        sb.AppendLine("of defect:<br/>");
                        sb.AppendFormat("<a href='{0}'>{1}</a>: {2}", artifact.Parent.Url, artifact.Parent.FormattedID, HttpUtility.HtmlEncode(artifact.Parent.Name));
                        sb.AppendLine();
                    }

                    sb.AppendLine("</td>");

                    sb.AppendLine("<td class='state-col' align=center>");

                    var state = Artifact.TryGetMember<string>(change.RawArtifact, "State");
                    if(state == "Completed")
                    {
                        sb.AppendLine("Completed");
                    }
                    else if(state == "Defined")
                    {
                    }
                    else if (state == "In-Progress")
                    {
                        if (change.Change.Estimate > 0 && change.Change.ToDo > 0)
                        {
                            var done = (int)(100 * (change.Change.Estimate - change.Change.ToDo) / change.Change.Estimate);
                            if (done > 0)
                            {
                                sb.AppendFormat("{0}%<br/>", done);
                                sb.AppendFormat(@"
            <table style='width: 100px; border-collapse: collapse; table-layout: fixed;' >
            <tr style='padding: 0px;'>
            <td style='width: {0}px; background-color: lightgreen; padding: 0px; font-size: 50%;'>&nbsp;</td>
            <td style='width: {1}px; background-color: gray padding: 0px; font-size: 50%;'>&nbsp;</td>
            </tr>
            </table>
            ", done, 100 - done);
                            }
                        }
                        else
                        {
                            sb.AppendLine("In Progress");
                        }
                    }
                    else
                    {
                        sb.AppendLine(state);
                    }

                    sb.AppendLine("</td>");

                    var c = GetHtmlDescriptiveChanges(change.Change);

                    sb.AppendFormat("<td class='notes-col'>{0}</td>", c);

                    sb.AppendLine("</tr>");
                    addTr = true;
                }
            }
            sb.AppendLine("</TABLE>");

            var body = sb.ToString();

            var app = new Microsoft.Office.Interop.Outlook.Application();

            Microsoft.Office.Interop.Outlook.MailItem msg;
            if (!string.IsNullOrWhiteSpace(Settings.Default.DailyReportTemplatePath))
            {
                msg = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItemFromTemplate(Settings.Default.DailyReportTemplatePath);
                msg.HTMLBody = BuildMailBody(body, msg.HTMLBody);
            }
            else
            {
                msg = (Microsoft.Office.Interop.Outlook.MailItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
                msg.Subject = "Daily Report";
                msg.HTMLBody = BuildMailBody(body);
            }

            msg.Display();

            Clipboard.SetText(sb.ToString());
        }
コード例 #48
0
ファイル: Common.cs プロジェクト: netthanhhung/Neos
    public static bool ExportActionToOutlook(Page page, Neos.Data.Action action)
    {
        string message = string.Empty;
        try
        {
            //First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object:
            Microsoft.Office.Interop.Outlook.Application outlookApp =
                new Microsoft.Office.Interop.Outlook.Application();

            //Next, create an instance of AppointmentItem object and set the properties:
            Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment =
                (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApp.CreateItem(
                    Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

            oAppointment.Subject = action.TypeActionLabel + "-" + action.CompanyName + "-" + action.CandidateFullName;
            oAppointment.Body = action.DescrAction;
            oAppointment.Location = action.LieuRDV;

            // Set the start date
            //if(action.DateAction.HasValue)
            //    oAppointment.Start = action.DateAction.Value;
            // End date
            if (action.Hour.HasValue)
            {
                oAppointment.Start = action.Hour.Value;
            }
            // Set the reminder 15 minutes before start
            oAppointment.ReminderSet = true;
            oAppointment.ReminderMinutesBeforeStart = 15;

            //Setting the sound file for a reminder:
            oAppointment.ReminderPlaySound = true;
            //set ReminderSoundFile to a filename.

            //Setting the importance:
            //use OlImportance enum to set the importance to low, medium or high
            oAppointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;

            /* OlBusyStatus is enum with following values:
            olBusy
            olFree
            olOutOfOffice
            olTentative
            */
            oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;

            //Finally, save the appointment:
            // Save the appointment
            //oAppointment.Save();

            // When you call the Save () method, the appointment is saved in Outlook.

            //string recipientsMail = string.Empty;
            //foreach (ListItem item in listEmail.Items)
            //{
            //    if (recipientsMail == string.Empty)
            //    {
            //        recipientsMail += item.Value;
            //    }
            //    else
            //    {
            //        recipientsMail += "; " + item.Value;
            //    }
            //}
            if (action.ContactID.HasValue)
            {
                string emailContact = string.Empty;
                List<CompanyContactTelephone> contactInfoList =
                    new CompanyContactTelephoneRepository().GetContactInfo(action.ContactID.Value);
                foreach (CompanyContactTelephone item in contactInfoList)
                {
                    if (item.Type == "E")
                    {
                        emailContact = item.Tel;
                        break;
                    }
                }
                //ParamUser currentUser = SessionManager.CurrentUser;
                if (!string.IsNullOrEmpty(emailContact))
                {
                    //oAppointment.RequiredAttendees = "*****@*****.**";
                    //oAppointment.OptionalAttendees = "*****@*****.**";
                    // Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email.
                    Microsoft.Office.Interop.Outlook.MailItem mailItem = oAppointment.ForwardAsVcal();

                    mailItem.To = emailContact;
                    mailItem.Send();
                    //oAppointment.Send();
                }
                else
                {
                    message = ResourceManager.GetString("messageExportActionNotHaveEmail");
                }
            }
        }
        catch (System.Exception ex)
        {
            message = ex.Message;
        }
        if (message != string.Empty)
        {
            string script1 = "<script type=\"text/javascript\">";

            script1 += " alert(\"" + message + "\")";
            script1 += " </script>";

            if (!page.ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                page.ClientScript.RegisterStartupScript(page.GetType(), "redirectUser", script1);
            return false;
        }
        else
        {
            return true;
        }
    }
コード例 #49
0
ファイル: OutboxMonitor.cs プロジェクト: killbug2004/WSProf
        public void Dispose()
        {
            _disposing = true;

            ClosePendingSubmitWaitHandles();

            if (_items != null)
            {
                _items.ItemAdd -= Items_ItemAdd;
                _items = null;
            }

            if (_outbox != null)
            {
                ((IDisposable)_outbox).Dispose();
                _outbox = null;
            }

            if (_ns != null)
            {
                ((IDisposable)_ns).Dispose();
                _ns = null;
            }

            if (_application != null)
            {
                ((IDisposable)_application).Dispose();
                _application = null;
            }
        }