[英]Using a textfile with mailadresses to sent emails to
我现在用
Message.to.add(xxxx@gmail.com);
Message.to.add(xxxx2@gmail.com);
哪个工作正常,但这些邮件地址需要能够由用户更改。
我可以从一个简单的文本文件中获取这些邮件地址,每行都有一个邮件地址吗?
const string file = "Emailontvangersconfig.txt";
if (System.IO.File.Exists(file))
{
string[] Lines = System.IO.File.ReadAllLines(file);
foreach (string Line in Lines)
//how do i add these to the message.to.add() and do i add all of them to one message.to.add?
}
else
{
System.IO.File.WriteAllText(file, "");
}
阅读@DiplomacyNotWar 和@John 的评论,我基本上有正确的代码,但我的其他代码格式是错误的。
const string file = "Emailontvangersconfig.txt";
if (System.IO.File.Exists(file))
{
string[] Lines = System.IO.File.ReadAllLines(file);
foreach (string Line in Lines)
message.to.add(Line)
}
else
{
System.IO.File.WriteAllText(file, "");
}
//Rest of the email sending code
```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.