应用内的电子邮件 [英] email from within app

查看:76
本文介绍了应用内的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试通过我的应用发送电子邮件.这是我的一些代码:

Hi All, I am trying to send an email from my app. Here is some of my code:

dynamic mail = null;
                    //--------Send Message-----------------------
                 
                //    mail = Interaction.CreateObject("CDO.Message");
                    mail = Server.CreateObject("CDO.Message");
                    mail.Subject = "Password set to expire";
                    mail.From = "fromAddress";
                
                  //  mail.To = Session("uemail");
              //      mail.To = HttpContext.Current.Session["uemail"];
                    mail.To = "toAddress";
               //     mail.TextBody = mtext;
                    mail.TextBody = "Hello World";
                    mail.Send();
                    mail = null;



这是在VB中进行的,我在线上进行了转换. Intellisense无法识别交互"一词.我尝试了Server,Intellisense给了我一些选择.当我到达mail.Send();我收到错误消息"SendUsing配置值无效".任何建议或想法将不胜感激.我对C#没有太多经验.我正在尝试通过硬编码往返地址来进行测试.

谢谢

D-Bar



This was in VB and I converted it online. Intellisense does not recognize the word "Interaction". I tried Server and Intellisense gave me some options. When I get to mail.Send(); I am getting error "The SendUsing configuration value is invalid." Any suggestions or ideas would be greatly appreciated. I do not have much experience with C#. I am trying to test by hardcoding the to and from addresses.

Thank-you,

D-Bar

推荐答案

看看这个提示: ^ ]
Have a look at this tip: Sending an Email in C# with or without attachments: generic routine.[^]



我在这里使用gmailaccount发送电子邮件.

Hi
I am sending an email using gmailaccount here.

using System.Net.Mail;

 private void button1_Click(object sender, RoutedEventArgs e)
        {
 string footer = "If you have any questions about appointment";
            string subject = "Appointment Canceled";
            string body = "Hi" + " " + "sent from google" + "\n\n" + footer;

            MailMessage message = new MailMessage();

            message.From = new MailAddress("Ngqandu.Anele@gmail.com");
            message.To.Add(new MailAddress("Anele.Ngqandu@live.nmmu.ac.za"));
            message.Subject = subject;
            message.Body = body;

            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("Ngqandu.Anele@gmail.com", "myGMAILpassword");

            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }





投票是否有帮助...





vote if it helps...


这篇关于应用内的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆