用于发送邮件不起作用的简单控制台应用程序

编程入门 行业动态 更新时间:2024-10-25 13:20:45
本文介绍了用于发送邮件不起作用的简单控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试编译一个简单的控制台应用程序来发送邮件, 我的主要想法是安排它到特定时间发送邮件 使用Windows计划任务后来。因此我需要一个exe文件 来完成这项工作。我使用这个命令编译了我的文件Emailtest.cs line csc /r:System.Web.dll Emailtest.cs 我得到了一个.exe文件但是当点击它或执行它时我不是接收任何邮件的b $ b。我不知道问题出在哪里 任何人都可以帮帮我 提前致谢 我给我了代码如下 使用System; 使用System.Web.Mail; 公共类Emailtest { public static void Main() { try { MailMessage objMail = new MailMessage(); objMail.From =" mailfrom" ;; objMail.To =" ge ***** **@yahoo" ;; objMail.Subject =" test mail"; objMail.BodyFormat = MailFormat.Html; objMail.Body =这是用于测试自动电子邮件。; SmtpMail.SmtpServer =" localhost"; SmtpMail.Send(objMail); Console.Write(发送给John Gera的邮件); } catch(例外情况) { Console.Write(ex.Message); } } }

i''m trying to compile a simple console application for sending a mail, my main idea is to schedule it to a particular time for sending mails using the windows schedular task lateron. Therefore i need an exe file to make that work. I compiled my file Emailtest.cs using this command line csc /r:System.Web.dll Emailtest.cs and i got an .exe file but when clicking it or executing it i''m not receiving any mail. I dont know where the problem is Can anyone help me out please Thanks in Advance I''m giving my code below using System; using System.Web.Mail; public class Emailtest { public static void Main() { try { MailMessage objMail = new MailMessage(); objMail.From = "mailfrom"; objMail.To = "ge*******@yahoo"; objMail.Subject = "test mail"; objMail.BodyFormat = MailFormat.Html; objMail.Body = "this is for testing automatic emails."; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(objMail); Console.Write("Mail Sent to John Gera"); } catch (Exception ex) { Console.Write(ex.Message); } } }

推荐答案

savvy写道: 我正在尝试编译一个简单的控制台应用程序来发送邮件,我的主要想法是安排它到特定时间发送邮件使用Windows计划任务。因此我需要一个exe文件来完成这项工作。我使用这个命令编译我的文件Emailtest.cs 行 csc /r:System.Web.dll Emailtest.cs 我得到了一个.exe文件,但点击它或执行它我我没有收到任何邮件。我不知道问题出在哪里 i''m trying to compile a simple console application for sending a mail, my main idea is to schedule it to a particular time for sending mails using the windows schedular task lateron. Therefore i need an exe file to make that work. I compiled my file Emailtest.cs using this command line csc /r:System.Web.dll Emailtest.cs and i got an .exe file but when clicking it or executing it i''m not receiving any mail. I dont know where the problem is

< snip> 好​​吧,当你从命令行执行它时,是否显示 例外情况? Jon

<snip> Well, when you executed it from the command line, does it show an exception? Jon

您是否收到任何例外情况? 您是否配置了本地邮件服务器? 在本地邮件中查看是否有邮件在队列中 欢呼, - Ignacio Machin, ignacio.machin AT dot.state.fl.us 佛罗里达州交通部 " savvy" <乔****** @ gmail>在消息中写道 news:11 ********************** @ f14g2000cwb.googlegr oups ... Hi, Are you getting any exception? Do you have configured your local mail server? Check in the local mailer to see if the mail is in the queue cheers, -- Ignacio Machin, ignacio.machin AT dot.state.fl.us Florida Department Of Transportation "savvy" <jo******@gmail> wrote in message news:11**********************@f14g2000cwb.googlegr oups... 我正在尝试编译一个简单的控制台应用程序来发送邮件,我的主要想法是安排它到特定时间发送邮件使用Windows计划任务。因此我需要一个exe文件来完成这项工作。我使用这个命令编译我的文件Emailtest.cs 行 csc /r:System.Web.dll Emailtest.cs 我得到了一个.exe文件,但点击它或执行它我我没有收到任何邮件。我不知道问题出在哪里任何人都可以帮助我在此先感谢 我在下面给我的代码 使用系统; 使用System.Web.Mail; 公共类Emailtest { public static void Main() {尝试 { MailMessage objMail = new MailMessage(); objMail.From =" mailfrom" ;; objMail.To =" ge ******* @ yahoo" ;; objMail.Subject =" test mail"; objMail.BodyFormat = MailFormat.Html; objMail.Body ="这是用于测试自动电子邮件。; SmtpMail.SmtpServer =" localhost"; SmtpMail.Send(objMail); Console.Write(发送给John Gera的邮件); } catch(Exception ex) { Console.Write(ex.Message); } } } i''m trying to compile a simple console application for sending a mail, my main idea is to schedule it to a particular time for sending mails using the windows schedular task lateron. Therefore i need an exe file to make that work. I compiled my file Emailtest.cs using this command line csc /r:System.Web.dll Emailtest.cs and i got an .exe file but when clicking it or executing it i''m not receiving any mail. I dont know where the problem is Can anyone help me out please Thanks in Advance I''m giving my code below using System; using System.Web.Mail; public class Emailtest { public static void Main() { try { MailMessage objMail = new MailMessage(); objMail.From = "mailfrom"; objMail.To = "ge*******@yahoo"; objMail.Subject = "test mail"; objMail.BodyFormat = MailFormat.Html; objMail.Body = "this is for testing automatic emails."; SmtpMail.SmtpServer = "localhost"; SmtpMail.Send(objMail); Console.Write("Mail Sent to John Gera"); } catch (Exception ex) { Console.Write(ex.Message); } } }

感谢您的时间和回复 现在正在工作 我的代码做了一些小改动..它的 SmtpMail.SmtpServer.Insert(0,localhost); 我能够发送邮件现在 再次非常感谢 Thanks for your time and responses Its working now I made a small change in my code .. its SmtpMail.SmtpServer.Insert( 0, "localhost"); and I''m able to send mails now Thank you very much once again

更多推荐

用于发送邮件不起作用的简单控制台应用程序

本文发布于:2023-11-15 22:09:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598392.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   发送邮件   应用程序   不起作用   简单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!