我没有依赖我的主机发送电子邮件,而是考虑使用我的Gmail帐户发送电子邮件.这些电子邮件是我在节目中播放的乐队的个性化电子邮件.有可能吗?
我有一个byte[]文件的内容.我想发送它作为附件使用System.Net.Mail.
我注意到附件类有1个重载,它接受一个流.
Attachment att = new Attachment(Stream contentStream,string name);
Run Code Online (Sandbox Code Playgroud)
是否有可能byte[]通过这个过载?
我需要通过命令行发送电子邮件,而无需任何人工交互以实现自动化.
我知道我们可以使用mailto命令,但这会组成电子邮件,主题,正文和所有内容,但除非我点击发送,否则它不会发送它.
我在线阅读我们可以使用blat但我不能使用除outlook之外的任何东西.
这是关闭后我发现链接到SOF帖子.
只是为了您的信息:我正在研究一些telnet命令发送电子邮件还没有成功. telnet用于发送电子邮件的命令
我需要发送一封邮件,包括例外情况(黄色死亡屏幕)作为附件.
我可以得到YSOD如下:
string YSODmarkup = lastErrorWrapper.GetHtmlErrorMessage();
if (!string.IsNullOrEmpty(YSODmarkup))
{
Attachment YSOD = Attachment.CreateAttachmentFromString(YSODmarkup, "YSOD.htm");
mm.Attachments.Add(YSOD);
}
Run Code Online (Sandbox Code Playgroud)
mm是类型MailMessage,但不发送邮件.
这里
System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("from", "to", "Exception-Details", htmlEmail.ToString());
Run Code Online (Sandbox Code Playgroud)
用于绑定邮件正文.
在此之后,仅添加附件.删除附件时,会发送邮件.
谁能帮我吗?
根据阿尔宾先生和保罗先生的评论,我正在更新以下内容
string YSODmarkup = Ex_Details.GetHtmlErrorMessage();
string p = System.IO.Directory.GetCurrentDirectory();
p = p + "\\trial.txt";
StreamWriter sw = new StreamWriter(p);
sw.WriteLine(YSODmarkup);
sw.Close();
Attachment a = new Attachment(p);
if (!string.IsNullOrEmpty(YSODmarkup))
{
Attachment YSOD = Attachment.CreateAttachmentFromString(YSODmarkup, "YSOD.html");
System.Net.Mail.Attachment(server.mappath("C:\\Documents and Settings\\user\\Desktop\\xml.docx"));
MyMailMessage.Attachments.Add(a);
}
Run Code Online (Sandbox Code Playgroud)
在这里,我将内容附加到文本文件并尝试相同.所以邮件没有发送.发送包含HTML标签的邮件是否有任何问题.因为我能够附加普通的文本文件.
c# ×3
.net ×2
email ×2
automation ×1
command-line ×1
gmail ×1
mailmessage ×1
outlook ×1
smtp ×1