当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Outlook.Application.CreateItem方法代码示例

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


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

示例1: OutlookPortal

		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);
			
		}
开发者ID:mind0n,项目名称:hive,代码行数:9,代码来源:OutlookPortal.cs

示例2: ExportActionToOutlook

    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 = "[email protected]";
                    //oAppointment.OptionalAttendees = "[email protected]";
                    // 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)
//.........这里部分代码省略.........
开发者ID:netthanhhung,项目名称:Neos,代码行数:101,代码来源:Common.cs

示例3: buttonGenerate_Click


//.........这里部分代码省略.........
                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());
        }
开发者ID:azarkevich,项目名称:TortoiseRally,代码行数:101,代码来源:MyWork.cs

示例4: timer_CntDwn_Tick

      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();
      }
开发者ID:AndreasDerFuchs,项目名称:KepiCrawler,代码行数:64,代码来源:KepiCrawler.cs

示例5: sendMessage

 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;
     }
 }
开发者ID:kenuyx,项目名称:SR-Wellness-Report-Tool,代码行数:28,代码来源:MailMessager.cs

示例6: OnButtonInvoiceEmailSelectionClicked

    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);
    }
开发者ID:netthanhhung,项目名称:Neos,代码行数:68,代码来源:InvoicesPage.aspx.cs


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