我正在尝试通过 asp.net webapp 发送文件。
我收到以下错误 8 次,我的代码中有不同的符号:类、结构或接口成员声明中的无效标记“=”
感觉就像我缺少一个功能,但我不确定。
这是我的整个 .cs 类代码:
// A namespace does not directly contain members such as fields or methods
namespace vCardGenerator.Website
{
public partial class SendvCard
{
public void Mailvcard()
{
//Class SendMail.cs
/*
string txtFile = txtFile.Text;
string strDir = "C:\\local\\vCardGenerator.Website"; //temp save location
string strFilename = Path.GetFileName(txtFile.PostedFile.FileName);
txtFile.PostedFile.SaveAs(strDir + strfilename);
mail.Attachments.Add(new MailAttachment(strDir + strFilename));
//Error with MailAttachment/MailAddress??
MailAddress;
if (useOverrideIfDebug && AppSettings.EmailToAddressOverride.Length > 0)
to = new MailAddress(AppSettings.EmailToAddressOverride, recipient.DisplayName);
else
to = recipient;
Exception error = null;
foreach (string server in AppSettings.SmtpServers)
{
*/
Mailer smtp = new Mailer(server);
}
smtp.AddAttachment = (@"C:\\Desktop\\FirstName_FamilyName.vcf");
smtp.FromAddress = "email";
smtp.Subject = "vCard";
smtp.MailBody = "vCard is added as file";
smtp.AddRecipient = txtMail.Text;
//to = txtMail.Text;
try
{
SmtpMail.Send();
}
catch (exception ex)
{
Responds.Write("Exception Occured: " + ex);
}
// Responds.Write("FAiled, try again please!")
finally
{
Responds.Write("De vCard has been sent succesfully!");
}
// delete vcard
// File.Delete(@"C:\\Bureaublad\\") + ("FirstName_LastName.vcf");
File.Delete(strDir + strFilename);
}
我是这方面的初学者,希望能得到有关如何解决这个问题的提示,因为谷歌再次让我失望了,我实际上是在搜索半天。但你必须从某个地方开始,对吗?
提前致谢,