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


C# ApplicationClass.CreateItem方法代码示例

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


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

示例1: button1_Click


//.........这里部分代码省略.........
                    {

                        reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
                        ServerReport serverReport = reportViewer1.ServerReport;

                        //Using the local server, no password
                        //reportViewer1.ServerReport.ReportServerUrl = new Uri("http://l1sql2-07/ReportServer");
                        //reportViewer1.ServerReport.ReportPath = "/HMIS - Management Reports/Data Integrity Report (LAHSA)";

                        btnStart.Text = "Connecting to reportServer";
                        //using the passwordProtected Server
                        reportViewer1.ServerReport.ReportServerUrl = new Uri("https://dw24.esserver.com/reportServer");
                        reportViewer1.ServerReport.ReportPath = "/HMIS Management Reports/Data Integrity Report (LAHSA)";

                        //Create an arrary with Report Parameters
                        progressBar1.PerformStep();
                        ArrayList reportParam = new ArrayList();
                        reportParam = ReportDefaultPatam(agency_list, contractNumber_list, contractType_list,string_Date_Start, string_Date_End, i);

                        //pass parameters into parameter arrary
                        ReportParameter[] param = new ReportParameter[reportParam.Count];
                        for (int k = 0; k < reportParam.Count; k++)
                        {
                            param[k] = (ReportParameter)reportParam[k];
                        }

                        //Pass Credentials
                        //NetworkCredential myCred = new NetworkCredential("JDecell", "1contr0lsth3ird3stiny*","");
                        //reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = myCred;
                        btnStart.Text = "Loading Credentials";
                        string userName = @"Dw24\GBarbosa";
                        string userPassword = "4Helping)ther$";
                        string userDomain = "";//LAHSADOM,Dw24

                        NetworkCredential myCred = new NetworkCredential(userName, userPassword, userDomain);
                        reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = myCred;

                        //Set paramets and generate report
                        btnStart.Text = "Pulling report for: " + agency_list[i] + "(" + (i + 1).ToString() + "/" + (dt.Rows.Count).ToString() + ")";
                        reportViewer1.ServerReport.SetParameters(param);
                        reportViewer1.RefreshReport();

                        //function creates and saves file
                        string fileName = ExportReport(reportViewer1, agency_list,contractNumber_list, program_list, i);

                        string reportFileName = fileName;

                        if (emailCheck == 1 && i == (dt.Rows.Count) - 1)
                        {
                            string[] emailList = { "[email protected]", "[email protected]" };

                            for (int j = 0; j < emailList.Length; j++)
                            {
                                //Create new email using outlook
                                btnStart.Text = "Compliling and Sending Email";
                                ApplicationClass outlookApp = new ApplicationClass();
                                MailItem mailItem = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);
                                mailItem.To = emailList[j];

                                timer.Stop();
                                //Get elapsed time
                                TimeSpan ts = timer.Elapsed;
                                //Format time
                                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

                                mailItem.Subject = "DIR reports complete";
                                mailItem.Body = "The DIR reports for the time period " + string_Date_Start + " to " + string_Date_End + " are complete.\n The reports can be found here: G:\\DA\\Rene\\AutoDIR \n Total run time " + elapsedTime;

                                //mailItem.Subject = "DIR for " + agency[i];
                                //mailItem.Body = "Here is the DIR for " + agency[i] + " for period " + string_Date_Start + " to " + string_Date_End + " The Report path: " + reportFileName;
                                //mailItem.Attachments.Add(reportFileName, (int)OlAttachmentType.olByValue, 1, reportFileName);

                                //send the email
                                mailItem.Send();
                            }

                        }

                        if (deleteFile == 1)
                        {
                            //Delete file once done
                            File.Delete(reportFileName);
                        }

                        progressBar1.PerformStep();

                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message + "\n" + ex.GetType().ToString() + "\n" + ex.StackTrace);
                        throw ex;

                    }
                }

                //pause for 1 min
                //System.Threading.Thread.Sleep(1 * 60 * 1000);
                btnStart.Text = "DIRs Complete, please close program";
            }
        }
开发者ID:angeles890,项目名称:localApps,代码行数:101,代码来源:frmMain.cs

示例2: Meeting

        public void Meeting(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);
                Application outlookApp = new ApplicationClass();
                AppointmentItem newMeeting = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem);
                newMeeting.MeetingStatus = OlMeetingStatus.olMeeting;

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                if (!string.IsNullOrEmpty(recipients[0]))
                {
                    foreach (Recipient recipRequired in recipients[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                    {
                        recipRequired.Type = (int)OlMeetingRecipientType.olRequired;
                    }
                }

                if (!string.IsNullOrEmpty(recipients[1]))
                {
                    foreach (Recipient recipOptional in recipients[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                    {
                        recipOptional.Type = (int)OlMeetingRecipientType.olOptional;
                    }
                }

                newMeeting.Subject = subject;
                newMeeting.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }
 
                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newMeeting.SendUsingAccount = account;
                    }
                }

                if (control.Context is Inspector)
                {
                    Inspector inspector = (Inspector)control.Context;
                    if (inspector.CurrentItem is AppointmentItem)
                    {
                        AppointmentItem m = inspector.CurrentItem as AppointmentItem;

                        // Get the recipients
                        string[] recipients2 = StaticHelper.GetRecipients(idParts[0], control.Id);
                        if (!string.IsNullOrEmpty(recipients2[0]))
                        {
                            foreach (Recipient recipRequired in recipients2[0].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                            {
                                recipRequired.Type = (int)OlMeetingRecipientType.olRequired;
                            }
                        }

                        if (!string.IsNullOrEmpty(recipients2[1]))
                        {
                            foreach (Recipient recipOptional in recipients2[1].Split(new[] { ';' }).Select(s => newMeeting.Recipients.Add(s)))
                            {
                                recipOptional.Type = (int)OlMeetingRecipientType.olOptional;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            m.Subject = newMeeting.Subject;
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newMeeting.Subject = newMeeting.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newMeeting.Subject + m.Subject;
                        }

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }
                    }
                }
                else
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ControlledVocabulary,代码行数:101,代码来源:Outlook2010CVAddIn.cs

示例3: Send

        public void Send(string buttonId, string subject, OlImportance importance)
        {
            try
            {
                Application outlookApp = new ApplicationClass();
                MailItem newEmail = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(buttonId);
                newEmail.To = recipients[0];
                newEmail.CC = recipients[1];
                newEmail.BCC = recipients[2];

                newEmail.Subject = subject;
                newEmail.Importance = importance;
                newEmail.Display(true);
            }
            catch (System.Exception ex)
            {
                StaticHelper.LogMessage(MessageType.Error, ex.ToString());
                throw;
            }
        }
开发者ID:Gordon-Beeming,项目名称:ControlledVocabulary,代码行数:23,代码来源:Outlook2010CVAddIn.cs

示例4: Send

        public void Send(IRibbonControl control, string subject, OlImportance importance)
        {
            try
            {
                string[] idParts = control.Id.Split(new[] { StaticHelper.SplitSequence }, StringSplitOptions.RemoveEmptyEntries);
                Application outlookApp = new ApplicationClass();
                MailItem newEmail = (MailItem)outlookApp.CreateItem(OlItemType.olMailItem);

                // Get the recipients
                string[] recipients = StaticHelper.GetRecipients(idParts[0], control.Id);
                newEmail.To = recipients[0];
                newEmail.CC = recipients[1];
                newEmail.BCC = recipients[2];
                newEmail.Subject = subject;
                newEmail.Importance = importance;

                string from = StaticHelper.GetApplicationSetting("MasterEmailAccount");
                if (string.IsNullOrEmpty(from))
                {
                    from = StaticHelper.GetFromAccount(idParts[0]);
                }

                if (!string.IsNullOrEmpty(from))
                {
                    // Retrieve the account that has the specific SMTP address.
                    Account account = GetAccountForEmailAddress(outlookApp, from);
                    if (account != null)
                    {
                        // Use this account to send the e-mail.
                        newEmail.SendUsingAccount = account;
                    }
                }

                if (control.Context is Inspector)
                {
                    Inspector inspector = (Inspector)control.Context;

                    // This handles sharepoint posts
                    if (inspector.CurrentItem is Microsoft.Office.Interop.Outlook.PostItem)
                    {
                        PostItem m = inspector.CurrentItem as PostItem;

                        if (string.IsNullOrEmpty(m.Subject))
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                m.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }
                            else
                            {
                                m.Subject = newEmail.Subject;
                            }
                        }
                        else
                        {
                            string standardSuffix = StaticHelper.GetStandardSuffix(idParts[0]);
                            if (!string.IsNullOrEmpty(standardSuffix))
                            {
                                newEmail.Subject = newEmail.Subject.Replace(standardSuffix, string.Empty);
                            }

                            m.Subject = newEmail.Subject + m.Subject;
                        }

                        return;
                    }

                    if (inspector.CurrentItem is MailItem)
                    {
                        MailItem m = inspector.CurrentItem as MailItem;
                        if (!string.IsNullOrEmpty(newEmail.To))
                        {
                            m.To = newEmail.To;
                        }

                        if (!string.IsNullOrEmpty(newEmail.CC))
                        {
                            m.CC = newEmail.CC;
                        }

                        if (!string.IsNullOrEmpty(newEmail.BCC))
                        {
                            m.BCC = newEmail.BCC;
                        }

                        m.Importance = newEmail.Importance;

                        if (!string.IsNullOrEmpty(from))
                        {
                            // Retrieve the account that has the specific SMTP address.
                            Account account = GetAccountForEmailAddress(outlookApp, from);
                            if (account != null)
                            {
                                // Use this account to send the e-mail.
                                m.SendUsingAccount = account;
                            }
                        }

                        if (string.IsNullOrEmpty(m.Subject))
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ControlledVocabulary,代码行数:101,代码来源:Outlook2010CVAddIn.cs

示例5: btnMerge_Click


//.........这里部分代码省略.........
                            else
                            {
                                fileExtension = ".docx";
                                format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault;
                            }

                            //Name of doc
                            string rootName = "";
                            if (headerPositions.Count != listRecieved.Count)
                            {
                                rootName = listRecieved[0].ToString();
                            }

                            string docNameRaw = "";
                            foreach (int pos in headerPositions)
                            {
                                docNameRaw += sheet1.Rows[i][pos].ToString()+"_";
                            }

                            if (rootName.Length > 1)
                            {
                                docNameRaw = rootName + "_" + docNameRaw;
                            }

                            string docName = saveToPath + docNameRaw.Substring(0,docNameRaw.Length-1) + fileExtension;

                            document1.SaveAs2(FileName: docName, FileFormat: format);

                            if (rbtnYes.Checked == true)
                            {

                                    //Email stuff
                                    ApplicationClass oApp = new ApplicationClass();
                                    MailItem mailItem = (MailItem)oApp.CreateItem(OlItemType.olMailItem);

                                    Recipients oRecips = mailItem.Recipients;

                                    List<string> sToRecipsList = new List<string>();

                                    string primaryEmail = sheet1.Rows[i][primaryEmailIndex].ToString();
                                    List<string> sCCRecipsList = new List<string>();
                                    List<int> ccIndexList = new List<int>();
                                    ccIndexList.Add(cc1Index);
                                    ccIndexList.Add(cc2Index);
                                    ccIndexList.Add(cc3Index);

                                    int numofCC = Convert.ToInt16(cmbCCNumber.SelectedItem.ToString());

                                    for (int iC = 0; iC < numofCC; iC++)
                                    {
                                        sCCRecipsList.Add(sheet1.Rows[i][ccIndexList[iC]].ToString());
                                    }

                                    sToRecipsList.Add(primaryEmail);

                                    foreach (string t in sToRecipsList)
                                    {
                                        if (string.IsNullOrEmpty(t) == false && t.Length > 1)
                                        {
                                            Recipient oTORecip = oRecips.Add(t);
                                            oTORecip.Type = (int)OlMailRecipientType.olTo;
                                            oTORecip.Resolve();
                                        }

                                    }
开发者ID:angeles890,项目名称:localApps,代码行数:66,代码来源:Form1.cs


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