简体   繁体   English

在C#中为电子邮件分配地址

[英]Assigning the address to an email in c#

I need an email component for my final project in intro to programming. 在编程入门的最后一个项目中,我需要一个电子邮件组件。 Just doing something simple, and the code I copied from my more complex email client had to be modified, and I'm having an issue with a line of it. 只是做一些简单的事情,我就不得不修改我从更复杂的电子邮件客户端复制的代码,而我对此却产生了疑问。

myMail.To.Add = new MailAddress(txtAddress.Text);

That's what I'm trying right now. 那就是我现在正在尝试的。 Getting: 获得:

Error 1 Cannot assign to 'Add' because it is a 'method group' C:\\ADixon\\Final\\Binary Project\\BinaryClock\\BinaryClock\\Form1.cs 567 21 BinaryClock 错误1无法分配给“添加”,因为它是一个“方法组” C:\\ ADixon \\ Final \\ Binary Project \\ BinaryClock \\ BinaryClock \\ Form1.cs 567 21 BinaryClock

Just want it to send the email to whatever's in the box... although thinking about it, maybe I'd be better off locking it into a listbox with a "set email" button... either way, I'd think I'd need this basic code to work. 只是希望它可以将电子邮件发送到框​​中的任何内容...尽管正在考虑,也许我最好通过“设置电子邮件”按钮将其锁定到列表框中...不管怎样,我想我需要此基本代码才能正常工作。 Off to work on my "set email" button and new listbox! 关闭以使用“设置电子邮件”按钮和新列表框!

MailAddressCollection.Add is a method. MailAddressCollection.Add是一种方法。 Nor a property, neither a field. 既不是财产,也不是田地。

You just need to 你只需要

myMail.To.Add(txtAddress.Text);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM