使用 Outlook 通过电子邮件发送文本框的内容
我编写了一个简单的应用程序,允许用户通过复选框选择库存项目。当选中这些项目时,将填充一个文本框,显示用户的输入。我想要一个类,它将获取文本框的内容并将其复制到新的 Outlook 电子邮件,其中收件人地址预先填充了 [电子邮件受保护]。 ASP.Net 对我来说很陌生,而且我是一个非常新的 C# 程序员,所以我不知道如何做到这一点。任何想法。
我在网上看到了一个例子,如下......
System.Web.Mail.MailMessage message=new System.Web.Mail.MailMessage();
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1 );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername","SmtpHostUserName" );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword","SmtpHostPassword" );
message.From="from e-mail";
message.To="to e-mail";
message.Subject="Message Subject";
message.Body="Message Body";
System.Web.Mail.SmtpMail.SmtpServer="SMTP Server Address";
System.Web.Mail.SmtpMail.Send(message);
但我到处都有错误,并认为我没有实施这一权利。有没有更简单的方法来做到这一点,或者只是一种我可能能够理解的方法。感谢所有的答案。我只能检查一项,但我很欣赏它们。
I have a simple application written that allows users to pick inventory items with checkboxes. When the items are checked a textbox is populated showing the user's input. I would like to have a class that would take the contents of the textbox and copy it to a new outlook email with the TO address pre-populated with [email protected]. ASP.Net is foreign to me and I am a very new C# coder SO I have no idea how to do this. Any ideas.
I have seen an example online as follows...
System.Web.Mail.MailMessage message=new System.Web.Mail.MailMessage();
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1 );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername","SmtpHostUserName" );
message.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword","SmtpHostPassword" );
message.From="from e-mail";
message.To="to e-mail";
message.Subject="Message Subject";
message.Body="Message Body";
System.Web.Mail.SmtpMail.SmtpServer="SMTP Server Address";
System.Web.Mail.SmtpMail.Send(message);
but I have errors everywhere and think that I'm not implementing this right. Is there a simpler way to do this or just a way I might be able to understand. Thanks to any and all answers. I can only check one but I appreciate them all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://support.microsoft.com/kb/310263
我猜您没有使用Outlook 对象库。如果您愿意,代码就在那里。
您需要进行的唯一更改是
TextBox1 包含您想要作为消息正文发送的所有内容。
http://support.microsoft.com/kb/310263
I am guessing you are not using the Outlook object library. If you want to, then the code is right there.
The only change you will have to make will be
where TextBox1 has the all the contents that you wanted to send as the message body.