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


C# Application.CreateItem方法代码示例

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


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

示例1: EnviarHTmlEmail

        /*
        public static ResultadoTransaccion EnviarHTmlEmail(string toValue, string subjectValue, string bodyValue)
        {
            ResultadoTransaccion res = new ResultadoTransaccion();
            try
            {
                oApp = new Application();
                oNameSpace = oApp.GetNamespace("MAPI");
                oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);
                oMailItem.To = toValue;
                oMailItem.Subject = subjectValue;
                if (oMailItem.HTMLBody.IndexOf("</BODY>") > -1)
                    oMailItem.HTMLBody = oMailItem.HTMLBody.Replace("</BODY>", bodyValue);

                oMailItem.SaveSentMessageFolder = oOutboxFolder;
                oMailItem.BodyFormat = OlBodyFormat.olFormatHTML;

                oMailItem.Send();

                res.Estado = Enums.EstadoTransaccion.Aceptada;
            }
            catch (Exception ex)
            {
                res.Descripcion = ex.Message;
                res.Estado = Enums.EstadoTransaccion.Rechazada;

                Log.EscribirLog(ex.Message);
            }

            return res;

        }
        */
        /// <summary>
        /// Metodo para el envio de Email desde el Modulo Calendario
        /// </summary>
        /// <param name="toValue">Email del receptor</param>
        /// <param name="subjectValue">Asunto del Email</param>
        /// <param name="bodyValue">Cuerpo del Email</param>        
        public static ResultadoTransaccion EnviarEmail(string toValue, string subjectValue, string bodyValue)
        {
            ResultadoTransaccion res = new ResultadoTransaccion();
            try
            {
                oApp = new Application();
                oNameSpace = oApp.GetNamespace("MAPI");
                oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);
                oMailItem.To = toValue;
                oMailItem.Subject = subjectValue;
                oMailItem.Body = bodyValue;
                oMailItem.SaveSentMessageFolder = oOutboxFolder;
                oMailItem.BodyFormat = OlBodyFormat.olFormatRichText;

                oMailItem.Send();

                res.Estado = Enums.EstadoTransaccion.Aceptada;
            }
            catch (Exception ex)
            {
                res.Descripcion = ex.Message;
                res.Estado = Enums.EstadoTransaccion.Rechazada;

                Log.EscribirLog(ex.Message);
            }

            return res;
        }
开发者ID:TarekMulla,项目名称:cra,代码行数:69,代码来源:EnvioEmail.cs

示例2: SaveMessage

        public static void SaveMessage(string[] recipients, string subject, string body, string[] attachments, string filepath)
        {
            var curpwd = FileIO.PresentWorkingDirectory();

            var outlookApplication = new Application();

            var mailObject = outlookApplication.CreateItem(OlItemType.olMailItem) as MailItem;

            mailObject.Body = body;
            mailObject.Subject = subject;

            if (recipients != null)
            {
                foreach (var recipient in recipients)
                {
                    mailObject.Recipients.Add(recipient);
                }
            }

            if (attachments != null)
            {
                foreach (var attachment in attachments)
                {
                    if ((attachment ?? string.Empty) != string.Empty)
                        mailObject.Attachments.Add(attachment);
                }
            }

            mailObject.SaveAs(FileIO.CombinePath(curpwd, "sample.msg"));
        }
开发者ID:Zeeger,项目名称:email-template,代码行数:30,代码来源:OutlookInterop.cs

示例3: SendMail

        protected static void SendMail(string body, string subject, string attachmentFile) {
            Application outlookApp = null;
            try {
                outlookApp = new Application();
            } catch (System.Exception ex) {
                GeneralLog.Write("Unable to start Outlook (exception data follows)");
                GeneralLog.Write(ex);
            }

            if (outlookApp == null) {
                if (attachmentFile != null) {
                    body = string.Format(CultureInfo.InvariantCulture, Resources.MailToFrownMessage,
                                         Path.GetDirectoryName(Path.GetTempPath()), // Trims trailing slash
                                         Environment.NewLine + Environment.NewLine);
                    VsAppShell.Current.ShowMessage(body, MessageButtons.OK);
                }

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName = string.Format(CultureInfo.InvariantCulture, "mailto://[email protected]?subject={0}&body={1}", subject, body);
                Process.Start(psi);

                if (attachmentFile != null) {
                    IntPtr pidl = IntPtr.Zero;
                    try {
                        pidl = NativeMethods.ILCreateFromPath(attachmentFile);
                        if (pidl != IntPtr.Zero) {
                            NativeMethods.SHOpenFolderAndSelectItems(pidl, 0, IntPtr.Zero, 0);
                        }
                    } finally {
                        if (pidl != IntPtr.Zero) {
                            NativeMethods.ILFree(pidl);
                        }
                    }
                }

            } else {
                try {
                    MailItem mail = outlookApp.CreateItem(OlItemType.olMailItem) as MailItem;

                    mail.Subject = subject;
                    mail.Body = body;
                    AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry;
                    if (currentUser.Type == "EX") {
                        mail.To = "[email protected]";
                        mail.Recipients.ResolveAll();
                    }

                    if (!string.IsNullOrEmpty(attachmentFile)) {
                        mail.Attachments.Add(attachmentFile, OlAttachmentType.olByValue);
                    }

                    mail.Display(Modal: false);
                } catch (System.Exception ex) {
                    GeneralLog.Write("Error composing Outlook e-mail (exception data follows)");
                    GeneralLog.Write(ex);
                }
            }
        }
开发者ID:int19h,项目名称:RTVS-OLD,代码行数:59,代码来源:SendMailCommand.cs

示例4: SendMail

 public void SendMail(IMailMessage mailMessage)
 {
     var app = new Application();
     var mail = app.CreateItem(OlItemType.olMailItem);
     mail.Body = mailMessage.Body;
     mail.Recipients.Add("[email protected]");
     mail.Recipients.Add("[email protected]");
     mailMessage.AttachmentPaths.ForEach(x => mail.Attachments.Add(x));
     mail.Subject = mailMessage.Subject;
     mail.Send();
 }
开发者ID:jleo3,项目名称:flatfoot,代码行数:11,代码来源:PostalWorker.cs

示例5: Send

        public void Send(System.Net.Mail.MailMessage message)
        {
            if (!OutlookIsRunning)
            {
                LaunchOutlook();
            }
            Recipients oRecips = null;
            Recipient oRecip = null;
            MailItem oMsg = null;

            try
            {
                _myApp = new Application();

                oMsg = (MailItem)_myApp.CreateItem(OlItemType.olMailItem);

                oMsg.HTMLBody = message.Body;
                oMsg.Subject = message.Subject;
                oRecips = (Recipients)oMsg.Recipients;


                foreach (var email in message.To)
                {
                    oRecip = (Recipient)oRecips.Add(email.Address);
                }

                foreach (var email in message.CC)
                {
                    oMsg.CC += string.Concat(email, ";");
                }

                List<string> filenames = Attach(message.Attachments, oMsg);
                oRecip.Resolve();

                (oMsg as _MailItem).Send();

                _mapiNameSpace = _myApp.GetNamespace("MAPI");
           

                DeleteTempFiles(filenames);
                Thread.Sleep(5000);
            }
            finally
            {
                if (oRecip != null) Marshal.ReleaseComObject(oRecip);
                if (oRecips != null) Marshal.ReleaseComObject(oRecips);
                if (oMsg != null) Marshal.ReleaseComObject(oMsg);
                if (_mapiNameSpace != null) Marshal.ReleaseComObject(_mapiNameSpace);
                if (_myApp != null) Marshal.ReleaseComObject(_myApp);
            }

        }
开发者ID:rcarubbi,项目名称:Carubbi.Components,代码行数:52,代码来源:OutlookInteropSender.cs

示例6: SendEmail

        public void SendEmail(string sender, string recipient, string subject, string body)
        {
            Application app = new Application();
            var mapi = app.GetNamespace("MAPI");
            mapi.Logon(ShowDialog: false, NewSession: false);
            var outbox = mapi.GetDefaultFolder(OlDefaultFolders.olFolderOutbox);

            MailItem email = app.CreateItem(OlItemType.olMailItem);
            email.To = recipient;
            email.Subject = subject;
            email.Body = body;
            email.Send();
        }
开发者ID:niuniuliu,项目名称:CSharp,代码行数:13,代码来源:OutlookSendEmail.cs

示例7: Main

        static void Main(string[] args)
        {
            Application app = new Application();
            var mapi = app.GetNamespace("MAPI");
            mapi.Logon(ShowDialog: false, NewSession: false);
            var outbox = mapi.GetDefaultFolder(OlDefaultFolders.olFolderOutbox);

            MailItem email = app.CreateItem(OlItemType.olMailItem);
            email.To = "[email protected]";
            email.Subject = "Autogenerated email";
            email.Body = "This is a test";
            email.Send();
//            WorkflowInvoker.Invoke(new Workflow1());
        }
开发者ID:niuniuliu,项目名称:CSharp,代码行数:14,代码来源:Program.cs

示例8: SendMail

        protected void SendMail(string body, string subject, string attachmentFile) {
            if (attachmentFile != null) {
                IntPtr pidl = IntPtr.Zero;
                try {
                    pidl = NativeMethods.ILCreateFromPath(attachmentFile);
                    if (pidl != IntPtr.Zero) {
                        NativeMethods.SHOpenFolderAndSelectItems(pidl, 0, IntPtr.Zero, 0);
                    }
                } finally {
                    if (pidl != IntPtr.Zero) {
                        NativeMethods.ILFree(pidl);
                    }
                }
            }

            Application outlookApp = null;
            try {
                outlookApp = new Application();
            } catch (System.Exception ex) {
                Services.Log.WriteAsync(LogVerbosity.Normal, MessageCategory.Error, "Unable to start Outlook: " + ex.Message).DoNotWait();
            }

            if (outlookApp == null) {
                var fallbackWindow = new SendMailFallbackWindow {
                    MessageBody = body
                };
                fallbackWindow.Show();
                fallbackWindow.Activate();

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName = string.Format(
                    CultureInfo.InvariantCulture,
                    "mailto:[email protected]?subject={0}&body={1}",
                    Uri.EscapeDataString(subject),
                    Uri.EscapeDataString(body));
                Services.ProcessServices.Start(psi);
            } else {
                try {
                    MailItem mail = outlookApp.CreateItem(OlItemType.olMailItem) as MailItem;
                    mail.Subject = subject;
                    mail.Body = body;
                    mail.To = "[email protected]";
                    mail.Display(Modal: false);
                } catch (System.Exception ex) {
                    Services.Log.WriteAsync(LogVerbosity.Normal, MessageCategory.Error, "Error composing Outlook e-mail: " + ex.Message).DoNotWait();
                }
            }
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:49,代码来源:SendMailCommand.cs

示例9: sendEmail

        public MailStatus sendEmail(List<string> ToMailAddress, List<string> CCMailAddress, string Subject, string HTMLMailBody)
        {
            if (ToMailAddress == null)
            {
                throw new System.Exception("No Mail Address acceptor provided.");
            }
            if (Subject == null && HTMLMailBody == null)
            {
                throw new System.Exception("Don't allow to deliver message without content");
            }
            try
            {
                Application app = new Application();
                StringBuilder stmp = new StringBuilder();
                NameSpace ns = app.GetNamespace("MAPI");
                ns.Logon("[email protected]",
                         "yeying19850707",
                         false, true);
                MailItem message = (MailItem)app.CreateItem(OlItemType.olMailItem);
                message.To = "";
                message.CC = "";
                foreach (string MsgTo in ToMailAddress)
                    message.To += MsgTo + "; ";

                if (CCMailAddress != null && CCMailAddress.Count > 0)
                {
                    foreach (string s in CCMailAddress)
                    {
                        stmp.Append(s);
                        stmp.Append("@microsoft.com;");
                    }
                    message.CC = stmp.ToString();
                }
                message.Subject = Subject;
                message.HTMLBody = HTMLMailBody;
                //message.Send();
                ns.Logoff();
                return MailStatus.OK;
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.ToString());

                return MailStatus.Error;
            }
        }
开发者ID:jiabailie,项目名称:self-projects,代码行数:47,代码来源:EmailSender.cs

示例10: ExportSessions

        public bool ExportSessions(string sExportFormat, Session[] oSessions, Dictionary<string, object> dictOptions, EventHandler<ProgressCallbackEventArgs> evtProgressNotifications)
        {
            IList<string> attachments = new List<string>();

            foreach (Session item in oSessions)
            {
                string file = Path.Combine(Path.GetTempPath(), item.id + ".txt");
                File.WriteAllText(file, item.ToString());
                attachments.Add(file);

                XmlDocument doc = new XmlDocument();
                try {
                    doc.Load(new MemoryStream(item.RequestBody));

                    file = Path.Combine(Path.GetTempPath(), "request_" + item.id + ".xml");
                    doc.Save(file);

                    attachments.Add(file);

                    doc.Load(new MemoryStream(item.ResponseBody));

                    file = Path.Combine(Path.GetTempPath(), "response_" + item.id + ".xml");
                    doc.Save(file);

                    attachments.Add(file);

                } catch
                {
                    //dann nicht :-);
                }

            }

            Application oApp = new Application();
            _MailItem oMailItem = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);

            foreach (var item in attachments)
            {
                oMailItem.Attachments.Add((object)item,OlAttachmentType.olEmbeddeditem, 1, (object)"Attachment");
            }

            oMailItem.Display();

            return true;
        }
开发者ID:HrKarlsson,项目名称:FiddlerExportNewMail,代码行数:45,代码来源:Class1.cs

示例11: SendOne

        public static void SendOne()
        {
            // Create an Outlook Application object.
            Application outLookApp = new Application();
            // Create a new TaskItem.
            MailItem newMail =
              (MailItem)outLookApp.CreateItem(OlItemType.olMailItem);
            // Configure the task at hand and save it.
            newMail.Body = "Don't forget to send DOM the links...";
            newMail.Importance = OlImportance.olImportanceHigh;
            newMail.Subject = "Get DOM to stop bugging me.";
            newMail.Recipients.Add("emailaddress");

            var curpwd = pwd();

            newMail.Attachments.Add(curpwd + "myattachment.txt");

            newMail.SaveAs("billburr.msg");

            Console.WriteLine(curpwd);
            Console.ReadKey();
        }
开发者ID:Zeeger,项目名称:email-template,代码行数:22,代码来源:OutlookInterop.cs

示例12: OnBtnExportClicked

    protected void OnBtnExportClicked(object sender, EventArgs e)
    {
        if (listEmail.Items.Count > 0 && !string.IsNullOrEmpty(Request.QueryString["ActionID"]))
        {
            try
            {
                int actionID = int.Parse(Request.QueryString["ActionID"]);
                ActionRepository repo = new ActionRepository();
                Neos.Data.Action action = repo.GetActionByActionID(actionID);
                if (action == null) return;
                //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:
                Application outlookApp = new Application();

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

                oAppointment.Subject = "This is the subject for my appointment";
                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;
                    DateTime end = oAppointment.Start.AddHours(1);
                    oAppointment.End = end;
                }
                // 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 = OlImportance.olImportanceHigh;

                /* OlBusyStatus is enum with following values:
                olBusy
                olFree
                olOutOfOffice
                olTentative
                */
                oAppointment.BusyStatus = 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;
                    }
                }

                //mailItem.SenderEmailAddress = "[email protected]";
                //mailItem.SenderName = "Thanh Hung";
                oAppointment.RequiredAttendees = recipientsMail;

                // Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email.
                MailItem mailItem = oAppointment.ForwardAsVcal();
                mailItem.To = "[email protected]";
                mailItem.Send();
                //oAppointment.Send();
            }
            catch (System.Exception ex)
            {
                string script1 = "<script type=\"text/javascript\">";

                script1 += " alert(\"" + ex.Message + "\")";
                script1 += " </script>";

                if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                    ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1);
                return;
            }
        }
        string script = "<script type=\"text/javascript\">";
        script += " OnBtnExportClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
            ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);
    }
开发者ID:netthanhhung,项目名称:Neos,代码行数:98,代码来源:ActionExportPopup.aspx.cs

示例13: CrearConvocatoriaReunion

        public ResultadoTransaccion CrearConvocatoriaReunion(clsVisita visita, bool Confirmada, bool aNombreDe,
            bool AvisoVendedor)
        {
            Application outlookApp = new Application();
            AppointmentItem agendaMeeting = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem);
            ResultadoTransaccion res = new ResultadoTransaccion();

            try
            {
                if (agendaMeeting != null)
                {
                    agendaMeeting.UserProperties.Add("IdVisitaSCC", OlUserPropertyType.olInteger, true,
                                                     OlFormatInteger.olFormatIntegerPlain);
                    agendaMeeting.UserProperties["IdVisitaSCC"].Value = visita.Id;
                    agendaMeeting.MeetingStatus = OlMeetingStatus.olMeeting;
                    agendaMeeting.Location = visita.Ubicacion;
                    agendaMeeting.Subject = visita.Asunto;
                    agendaMeeting.Body = visita.Descripcion;

                    agendaMeeting.Start = visita.FechaHoraComienzo;
                    agendaMeeting.End = visita.FechaHoraTermino;

                    TimeSpan diff;
                    diff = visita.FechaHoraTermino - visita.FechaHoraComienzo;

                    agendaMeeting.Duration = Convert.ToInt16(diff.TotalMinutes);

                    foreach (var asistente in visita.AsistentesCraft)
                    {
                        if (!aNombreDe)
                        {
                            if (visita.UsuarioOrganizador.Id != asistente.Usuario.Id)
                            {
                                Recipient rec = agendaMeeting.Recipients.Add(asistente.Usuario.Email);
                                rec.Type = (int)OlMeetingRecipientType.olRequired;
                            }
                        }
                        else
                        {
                            if (visita.EsReunionInterna)
                            {
                                if (visita.UsuarioOrganizador.Id != asistente.Usuario.Id)
                                {
                                    Recipient rec = agendaMeeting.Recipients.Add(asistente.Usuario.Email);
                                    rec.Type = (int)OlMeetingRecipientType.olRequired;
                                }
                            }
                            else
                            {
                                if (visita.UsuarioOrganizador.Id != asistente.Usuario.Id &&
                                    visita.Vendedor.Id != asistente.Usuario.Id)
                                {
                                    Recipient rec = agendaMeeting.Recipients.Add(asistente.Usuario.Email);
                                    rec.Type = (int)OlMeetingRecipientType.olRequired;
                                }

                                if (visita.Vendedor.Id == asistente.Usuario.Id)
                                    agendaMeeting.Body = BodyAvisoVendedorVisitaOrganizada(visita);
                            }
                        }
                    }

                    foreach (var producto in visita.Cliente.ProductosPreferidos)
                    {
                        if (producto.Customer != null)
                        {
                            Recipient rec = agendaMeeting.Recipients.Add(producto.Customer.Email);
                            rec.Type = (int)OlMeetingRecipientType.olRequired;
                        }
                    }
                    ((_AppointmentItem)agendaMeeting).Send();

                    res.Estado = Enums.EstadoTransaccion.Aceptada;

                }
            }
            catch (Exception ex)
            {
                res.Estado = Enums.EstadoTransaccion.Rechazada;
                res.Descripcion = ex.Message;

                Log.EscribirLog(ex.Message);
            }

            return res;
        }
开发者ID:TarekMulla,项目名称:cra,代码行数:86,代码来源:EnvioMailObject.cs

示例14: EnviarMaiSalesLead

        public ResultadoTransaccion EnviarMaiSalesLead(ClsSalesLead salesLead)
        {
            var res = new ResultadoTransaccion();
            try
            {
                oApp = new Application();
                oNameSpace = oApp.GetNamespace("MAPI");
                oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                var mail = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);

                var body = CrearCuerpoMailSalesLead(salesLead,
                                                    Path.Combine(System.Windows.Forms.Application.StartupPath,
                                                                 @"mailSalesLead\template.html"));
                if (!string.IsNullOrEmpty(mail.HTMLBody) && mail.HTMLBody.ToLower().Contains("</body>"))
                {
                    var imagePath = Path.Combine(System.Windows.Forms.Application.StartupPath,
                                                 @"mailSalesLead\logo.png");

                    mail.Subject = "New Sales Lead";

                    //mail.To = salesLead.Agente.Email;
                    mail.To = salesLead.Agente.Email;

                    //CONTENT-ID
                    const string schemaPrAttachContentId = @"http://schemas.microsoft.com/mapi/proptag/0x3712001E";
                    var contentId = Guid.NewGuid().ToString();

                    mail.Attachments.Add(imagePath, OlAttachmentType.olEmbeddeditem, mail.HTMLBody.Length, Type.Missing);
                    mail.Attachments[mail.Attachments.Count].PropertyAccessor.SetProperty(schemaPrAttachContentId,
                                                                                          contentId);

                    //Create and add banner
                    body = body.Replace("[logo]", string.Format(@"<img src=""cid:{1}"" />", "", contentId));

                    if (mail.HTMLBody.IndexOf("</BODY>") > -1)
                        mail.HTMLBody = mail.HTMLBody.Replace("</BODY>", body);

                    mail.Display(true);
                }
            }
            catch (Exception e)
            {
                res.Descripcion = e.Message;
                res.Estado = Enums.EstadoTransaccion.Rechazada;
                Log.EscribirLog(e.Message);
            }
            return res;
        }
开发者ID:TarekMulla,项目名称:cra,代码行数:48,代码来源:EnvioMailObject.cs

示例15: EnviarMailCotizacionDirecta

        public ResultadoTransaccion EnviarMailCotizacionDirecta(String subject, String html, List<String> pathAdjuntos)
        {
            var res = new ResultadoTransaccion();
            try
            {
                oApp = new Application();
                oNameSpace = oApp.GetNamespace("MAPI");
                oOutboxFolder = oNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                var mail = (_MailItem)oApp.CreateItem(OlItemType.olMailItem);
                mail.Subject = subject;
                mail.HTMLBody = html;

                //mail.Attachments.Add(foo, OlAttachmentType.olByValue, mail.HTMLBody.Length, Type.Missing);
                if (pathAdjuntos != null)
                    foreach (var adj in pathAdjuntos)
                        mail.Attachments.Add((object)adj, OlAttachmentType.olEmbeddeditem, 1, (object)"Attachment");

                mail.Save();
                mail.Display(false);

            }
            catch (Exception e)
            {
                res.Descripcion = e.Message;
                res.Estado = Enums.EstadoTransaccion.Rechazada;
                Log.EscribirLog(e.Message);
            }
            return res;
        }
开发者ID:TarekMulla,项目名称:cra,代码行数:29,代码来源:EnvioMailObject.cs


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