在搜索论坛后,虽然这个问题被问到并回答了,但我的具体问题并不在修复之列。
我在SCADA系统中工作,所以是System.Web.Mail。命令都是我可以使用的。
'是我已经尝试过的行。
这是我收到的邮件可以发送但没有附件的内容
Dim Day as System.dateTime;
Dim sDay as String;
'Dim attachment as System.Web.Mail.MailAttachment;
'Dim attachment as string;
Day = new system.dateTime();
Day = now();
Day = system.dateTime.Parse(Day).AddDays(-1);
sDay = Day.day;
System.Web.Mail.SmtpMail.SmtpServer = "smtp.mdu.com";
System.Web.Mail.MailAttachment("G:\Test\" + me.IGCFilename + sday + ".txt");
'System.Web.Mail.MailAttachment attachment = new System.Web.Mail.MailAttachment("G:\Test\" +
me.IGCFilename + sday + ".txt");
System.Web.Mail.SmtpMail.Send
(
{from: } "DoNotReply@cngc.com;",
{to: } me.EmailTo,
{subject: } "Daily Gate Volumes sent to Williams",
{body: } "Gas Day Volumes"
);
me.EmailFileNow = false;
答案 0 :(得分:0)
看起来代码使用的是Send(String,String,String,String)方法,该方法发送一条从,到,主题的正文消息。
要添加带有附件的完整电子邮件,请尝试以下所有操作:
Dim Day as System.dateTime;
Dim sDay as String;
Day = new system.dateTime();
Day = now();
Day = system.dateTime.Parse(Day).AddDays(-1);
sDay = Day.day;
MailAttachment att = System.Web.Mail.MailAttachment("G:\Test\" + me.IGCFilename + sday + ".txt");
emailMessage = new MailMessage();
emailMessage.From = "DoNotReply@cngc.com;";
emailMessage.To = "me.EmailTo";
emailMessage.Subject = "Daily Gate Volumes sent to Williams";
emailMessage.Body = "Gas Day Volumes";
emailMessage.Attachments.Add(att);
System.Web.Mail.SmtpMail.SmtpServer = "smtp.mdu.com";
System.Web.Mail.SmtpMail.Send(emailMessage);
me.EmailFileNow = false;
没有vb SCADA系统,我无法测试它,但是上面的代码是.net SmtpMail代码。