• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Outlook.Application类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Application的典型用法代码示例。如果您正苦于以下问题:C# Application类的具体用法?C# Application怎么用?C# Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Application类属于Microsoft.Office.Interop.Outlook命名空间,在下文中一共展示了Application类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: button1_Click

        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.Application application = new Outlook.Application();
            Outlook.NameSpace ns = application.GetNamespace("MAPI");

            try
            {
                //get selected mail item
                Object selectedObject = application.ActiveExplorer().Selection[1];
                Outlook.MailItem selectedMail = (Outlook.MailItem)selectedObject;

                //create message
                Outlook.MailItem newMail = application.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
                newMail.Recipients.Add(ReadFile());
                newMail.Subject = "SPAM";
                newMail.Attachments.Add(selectedMail, Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem);

                newMail.Send();
                selectedMail.Delete();

                System.Windows.Forms.MessageBox.Show("Spam notification has been sent.");
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("You must select a message to report.");
            }
        }
开发者ID:jamesfaske,项目名称:Report-Spam,代码行数:27,代码来源:Ribbon1.cs


示例2: Main

    public static void Main(string[] args)
    {
        Outlook.Application application = null;

        application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
        application = new Outlook.Application();
        Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");

        Outlook.MAPIFolder userFolder = null;
        Outlook.MAPIFolder emailFolder = nameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

        try
        {
            foreach (Outlook.MailItem item in emailFolder.Items)
            {
                if (SearchAttachments(item.Attachments, args[0]))
                {
                    Console.WriteLine(item.Subject);
                    break;
                }

            }
        }
        catch (Exception message)
        {
            Console.WriteLine(message);
        }
    }
开发者ID:perchouli,项目名称:works,代码行数:28,代码来源:read_outlook.cs


示例3: CreateRecurringAppointment

 private void CreateRecurringAppointment()
 {
     Outlook.Application outlookApp = new Outlook.Application();
     try
     {
         Outlook.AppointmentItem appt = outlookApp.CreateItem(
             Outlook.OlItemType.olAppointmentItem)
             as Outlook.AppointmentItem;
         appt.Subject = "Customer Review";
         appt.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
         appt.Location = "36/2021";
         appt.Start = DateTime.Parse("10/20/2006 10:00 AM");
         appt.End = DateTime.Parse("10/20/2006 11:00 AM");
         appt.Body = "Testing";
         Outlook.Recipient recipRequired =
             appt.Recipients.Add("Ryan Gregg");
         recipRequired.Type =
             (int)Outlook.OlMeetingRecipientType.olRequired;
         Outlook.Recipient recipOptional =
             appt.Recipients.Add("Peter Allenspach");
         recipOptional.Type =
             (int)Outlook.OlMeetingRecipientType.olOptional;
         Outlook.Recipient recipConf =
            appt.Recipients.Add("Conf Room 36/2021 (14) AV");
         recipConf.Type =
             (int)Outlook.OlMeetingRecipientType.olResource;
         appt.Recipients.ResolveAll();
         appt.Display(false);
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show("The following error occurred: " + ex.Message);
     }
 }
开发者ID:danw0z,项目名称:pdfToOutlook,代码行数:34,代码来源:MainWindow.xaml.cs


示例4: Page_PreRender

    protected void Page_PreRender(object sender, EventArgs e)
    {
        OutLook._Application outlookObj = new OutLook.Application();

         //Button btnPlaySong =  (Button) this.form.FindControl("btnPlaySong");
        //Song.rr  = Request.PhysicalApplicationPath.ToString();
    }
开发者ID:elieli,项目名称:nonProfit,代码行数:7,代码来源:BuyersFormold.aspx.cs


示例5: OLCalReader

 public OLCalReader(String profileName)
 {
     myOutlook = new Outlook.Application ();
     myProfile = myOutlook.Session;
     this.profileName = profileName;
     Logon ();
 }
开发者ID:wrogner,项目名称:FreeMiCal,代码行数:7,代码来源:OLCalReader.cs


示例6: CreateOutlookEmail

 }//end of Email Method
 public static void CreateOutlookEmail(List<string> toList, string subject, string msg, string attachementFileName = null)
 {
     try
     {
         Outlook.Application outlookApp = new Outlook.Application();
         Outlook.MailItem mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
         mailItem.Subject = subject;
         Outlook.Recipients oRecips = mailItem.Recipients;
         if (toList != null)
         {
             foreach (var i in toList)
             {
                 Outlook.Recipient oRecip = oRecips.Add(i);
                 oRecip.Resolve();
             }
         }
         
         if (attachementFileName != null)
         {
             //int iPosition = (int) mailItem.Body.Length + 1;
             //int iAttachType = (int) Outlook.OlAttachmentType.olByValue;
             //now attached the file
             mailItem.Attachments.Add(attachementFileName);
         }
         mailItem.HTMLBody += msg;
         mailItem.Display(true);
     }
     catch (Exception eX)
     {
         throw new Exception("cDocument: Error occurred trying to Create an Outlook Email"
                             + Environment.NewLine + eX.Message);
     }
 }
开发者ID:FrankMedvedik,项目名称:coopcheck,代码行数:34,代码来源:EmailSvc.cs


示例7: ThisAddIn_Startup

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Microsoft.Office.Interop.Outlook._Application OutlookObject = new Microsoft.Office.Interop.Outlook.Application();
            //Create a new Contact Item
            Microsoft.Office.Interop.Outlook.ContactItem contact = OutlookObject.CreateItem(
                                    Microsoft.Office.Interop.Outlook.OlItemType.olContactItem);

            //Set different properties of this Contact Item.
            contact.FirstName = "Mellissa";
            contact.LastName = "MacBeth";
            contact.JobTitle = "Account Representative";
            contact.CompanyName = "Contoso Ltd.";
            contact.OfficeLocation = "36/2529";
            contact.BusinessTelephoneNumber = "4255551212 x432";
            contact.BusinessAddressStreet = "1 Microsoft Way";
            contact.BusinessAddressCity = "Redmond";
            contact.BusinessAddressState = "WA";
            contact.BusinessAddressPostalCode = "98052";
            contact.BusinessAddressCountry = "United States of America";
            contact.Email1Address = "[email protected]";
            contact.Email1AddressType = "SMTP";
            contact.Email1DisplayName = "Melissa MacBeth ([email protected])";

            //Save the Contact to disc
            contact.SaveAs("OutlookContact.vcf", OlSaveAsType.olVCard);
        }
开发者ID:ruanzx,项目名称:Aspose_Email_NET,代码行数:26,代码来源:ThisAddIn.cs


示例8: InitializeObjects

 private void InitializeObjects()
 {
     _myApp = new Microsoft.Office.Interop.Outlook.Application();
     _mapiNameSpace = _myApp.GetNamespace("MAPI");
     _mapiFolder = _mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
     
 } 
开发者ID:rcarubbi,项目名称:Carubbi.Components,代码行数:7,代码来源:OutlookInteropReceiver.cs


示例9: ThisAddIn_Startup

 private void ThisAddIn_Startup(object sender, System.EventArgs e)
 {
     OutlookApplication = Application as Outlook.Application;
     OutlookInspectors = OutlookApplication.Inspectors;
     OutlookInspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(OutlookInspectors_NewInspector);
     OutlookApplication.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(OutlookApplication_ItemSend);
 }
开发者ID:yasiralam,项目名称:OutlookAddin,代码行数:7,代码来源:ThisAddIn.cs


示例10: SettingsManager

 public SettingsManager(Outlook.Application app)
 {
     Application = app;
     this.profile = Application.Session.CurrentProfileName;
     Outlook.Folder oInbox = (Outlook.Folder)Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
     this.storage = oInbox.GetStorage("calcifyStore", Outlook.OlStorageIdentifierType.olIdentifyBySubject);
 }
开发者ID:johanvanzijl,项目名称:Calcify,代码行数:7,代码来源:SettingsManager.cs


示例11: Initialise

        public Microsoft.Office.Interop.Outlook.Application Initialise()
        {
           
            if (!MapiProfileHelperIsRegistered())
            {
                RegisterMapiProfileHelper();
                {
                    if (!MapiProfileHelperIsRegistered())
                        throw new System.Exception("You need to register the MapiProfileHelper for these tests to run.");
                }
            }
            m_bOutlookWasRunningBeforeSenderStarted = IsOutlookRuuning();
            HideOutlookLogonProfileDialog();
            SetMailProfile();
            try
            {
                m_outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
            }
            catch (COMException)
            {
                Thread.Sleep(2000); // Outlook 2010 seems twitchy and can respond with an error indicating its not ready - wait and try again
                m_outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
            }


            return m_outlookApplication;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:27,代码来源:EmailSender.cs


示例12: SendEMailThroughOutlook

 public static void SendEMailThroughOutlook(List<string> toList, string subject, string msg, string attachementFileName = null  )
 {
         // Create the Outlook application.
         Outlook.Application oApp = new Outlook.Application();
         // Create a new mail item.
         Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
         // Set HTMLBody. 
         //add the body of the email
         oMsg.HTMLBody += msg;
         //Add an attachment.
          String sDisplayName = "Coopcheck Log";
         int iPosition = (int)oMsg.Body.Length + 1;
         int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
         // now attached the file
         Outlook.Attachment oAttach = oMsg.Attachments.Add(attachementFileName, iAttachType, iPosition, sDisplayName);
         //Subject line
         oMsg.Subject = subject;
         // Add a recipient.
         Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
         // Change the recipient in the next line if necessary.
         foreach (var i in toList)
         {
             Outlook.Recipient oRecip = (Outlook.Recipient) oRecips.Add(i);
             oRecip.Resolve();
         }
         oMsg.Send();
     }
开发者ID:FrankMedvedik,项目名称:coopcheck,代码行数:27,代码来源:EmailSvc.cs


示例13: GetCalendarEvents

        public List<CalendarEvent> GetCalendarEvents(DateTime rangeFrom, DateTime rangeTo)
        {
            var app = new Outlook.Application();

            Outlook.Folder calendarFolder = app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;

            Outlook.Items outlookEvents = getAppointmentsInRange(calendarFolder, rangeFrom, rangeTo);

            List<CalendarEvent> calendarEvents = new List<CalendarEvent>();

            foreach (Outlook.AppointmentItem outlookEvent in outlookEvents)
            {
                var calendarEvent = new OutlookCalendarEvent()
                {
                    DateFrom = outlookEvent.Start,
                    DateTo = outlookEvent.End,
                    Description = string.Format("{0}", outlookEvent.Body),
                    Location = outlookEvent.Location,
                    Title = outlookEvent.Subject,
                    ID = outlookEvent.GlobalAppointmentID,
                    SourceID = outlookEvent.ItemProperties["SourceID"] != null ? outlookEvent.ItemProperties["SourceID"].ToString() : outlookEvent.GlobalAppointmentID
                };

                calendarEvents.Add(calendarEvent);
            }

            return calendarEvents;
        }
开发者ID:netxph,项目名称:gosync,代码行数:28,代码来源:OutlookCalendarProvider.cs


示例14: Print

		public override string Print(WorkbookItem wi)
		{
			using (new WsActivationContext())
			{
				string destination = Utilities.GetTemporaryFileWithPdfExtension();

				Outlook._Application app = new Outlook.Application();
				Outlook._MailItem mailItem = app.Session.OpenSharedItem(wi.FileName) as Outlook._MailItem;
				try
				{
				if (mailItem == null)
				{
					return null;
				}

					Publisher.PublishWithOutlook(destination, mailItem);
				}
				finally
				{
					if (mailItem != null)
					{
					mailItem.Close(Outlook.OlInspectorClose.olDiscard);
						System.Runtime.InteropServices.Marshal.ReleaseComObject(mailItem);
				}
				}

				return destination;
			}
		}
开发者ID:killbug2004,项目名称:WSProf,代码行数:29,代码来源:OutlookPrinterController.cs


示例15: ThisAddIn_Startup

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // Create an object of type Outlook.Application
            Outlook.Application objOutlook = new Outlook.Application();

            //Create an object of type olMailItem
            Outlook.MailItem oIMailItem = objOutlook.CreateItem(Outlook.OlItemType.olMailItem);

            //Set properties of the message file e.g. subject, body and to address
            //Set subject
            oIMailItem.Subject = "This MSG file is created using Office Automation.";
            //Set to (recipient) address
            oIMailItem.To = "[email protected]";
            //Set body of the email message
            oIMailItem.HTMLBody = "<html><p>This MSG file is created using VBA code.</p>";

            //Add attachments to the message
            oIMailItem.Attachments.Add("image.bmp");
            oIMailItem.Attachments.Add("pic.jpeg");

            //Save as Outlook MSG file
            oIMailItem.SaveAs("testvba.msg");

            //Open the MSG file
            oIMailItem.Display();
        }
开发者ID:ruanzx,项目名称:Aspose_Email_NET,代码行数:26,代码来源:ThisAddIn.cs


示例16: sendEmail

        private void sendEmail(EmailObject eml)
        {
            string myDate = today.ToString("dd MMMM yyyy");
            //new outlook instance

            Outlook.Application app = new Outlook.Application();
            Outlook.MailItem mail = app.CreateItem(Outlook.OlItemType.olMailItem);
            {
                string[] files = Directory.GetFiles(AttachmentDestination);
                int fileCount = 0;
                foreach (string file in files)
                {
                    Console.WriteLine("attatching file : " + file);
                    mail.Attachments.Add(file);
                    fileCount++;
                }
                if (fileCount > 0)
                {
                    mail.Importance = Outlook.OlImportance.olImportanceHigh;
                    mail.Subject = myDate + " " + eml.EmailSubject;
                    mail.To = eml.Emails;
                    mail.Body = eml.EmailBody;
                    Console.WriteLine("sending...");
                    mail.Send();
                }
            }
        }
开发者ID:MattPaul25,项目名称:Database_Error_Reporting,代码行数:27,代码来源:SendEmail.cs


示例17: GetApplicationObject

        //This function is taken from the MSDN :
        //https://msdn.microsoft.com/en-us/library/office/ff462097.aspx
        public static Outlook.Application GetApplicationObject()
        {
            Outlook.Application application = null;

            // Check if there is an Outlook process running.
            if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
            {
                try
                {
                    // If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
                    application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
                }
                catch
                {
                    //log to windows logs
                    application = new Outlook.Application();
                    Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
                    nameSpace.Logon("", "", false, Missing.Value);
                    nameSpace = null;
                }

            }
            else
            {

                // If not, create a new instance of Outlook and log on to the default profile.
                application = new Outlook.Application();
                Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
                nameSpace.Logon("", "", false, Missing.Value);
                nameSpace = null;
            }

            // Return the Outlook Application object.
            return application;
        }
开发者ID:Alymcgeel,项目名称:ContextSearchHelper,代码行数:37,代码来源:Helper.cs


示例18: Execute

 protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
 {
     // Create an Outlook Application object. 
     Outlook.Application outlookApp = new Outlook.Application();
     // Create a new TaskItem.
     Outlook.NoteItem newNote = (Outlook.NoteItem)outlookApp.CreateItem(Outlook.OlItemType.olNoteItem);
     // Configure the task at hand and save it.
     if (this.Parent.Parent is ParallelActivity)
     {
         newNote.Body = (this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty;
         if ((this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
         {
             MessageBox.Show("Creating Outlook Note");
             newNote.Save();
         }
     }
     else if (this.Parent.Parent is SequentialWorkflowActivity)
     {
         newNote.Body = (this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty;
         if ((this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
         {
             MessageBox.Show("Creating Outlook Note");
             newNote.Save();
         }
     }
     return ActivityExecutionStatus.Closed;
 }
开发者ID:ssickles,项目名称:archive,代码行数:27,代码来源:OutlookNote.cs


示例19: AddAppointment

        public void AddAppointment(Appointment apt)
        {
            try
            {
                Outlook.Application outlookApp = new Outlook.Application(); // creates new outlook app
                Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem); // creates a new appointment

                oAppointment.Subject = apt.Subject;
                oAppointment.Body = apt.Body;
                oAppointment.Location = apt.Location;
                oAppointment.Start = Convert.ToDateTime(apt.StartTime);
                oAppointment.End = Convert.ToDateTime(apt.EndTime);
                oAppointment.ReminderSet = true;
                oAppointment.ReminderMinutesBeforeStart = apt.ReminderMinutesBeforeStart;
                oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
                oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;
                oAppointment.RequiredAttendees = apt.RequiredAttendees;

                oAppointment.Save();

                Outlook.MailItem mailItem = oAppointment.ForwardAsVcal();
                // email address to send to
                mailItem.To = apt.RequiredAttendees +";" + apt.Organizer; //" [email protected]";
                // send
                mailItem.Send();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\r\n" + ex.InnerException + "\r\n" + "\r\n");
            }
        }
开发者ID:Bigtalljosh,项目名称:AddToOutlook,代码行数:31,代码来源:OutlookHandle.cs


示例20: SendEmailUsingOutLook

        public void SendEmailUsingOutLook(string witBody,String witName, List<Docs> docs)
        {

            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);

            email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
            email.Subject = witName;
            email.HTMLBody = witBody;

            if (docs != null && docs.Count > 0) {

                foreach (var doc in docs) {
                    if (doc.docId != null)
                    {
                        email.Attachments.Add(doc.localPath + "" + doc.fileName, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing);
                    }
                }
            }
           

            email.Display(true);

        }
开发者ID:soumyaansh,项目名称:Outlook-Widget,代码行数:27,代码来源:TextToEmailBody.cs



注:本文中的Microsoft.Office.Interop.Outlook.Application类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PowerPoint.Shape类代码示例发布时间:2022-05-26
下一篇:
C# Excel.Worksheet类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap