使用以下代码发送邮件:
{ string from="abcd@gmail.com";
using ( MailMessage mail=new MailMessage(from, txtTo. Text) )
{ mail. Subject=txtSubject. Text;
mail. Body=txtMessage. Text;
if ( fileUploader. HasFile )
{
string fileName=Path. GetFileName(fileUploader. PostedFile. FileName);
mail. Attachments. Add(new Attachment(fileUploader. PostedFile. InputStream, fileName));
}
mail. IsBodyHtml=false;
SmtpClient smtp=new SmtpClient();
smtp. Host="smtp.gmail.com";
smtp. EnableSsl=true;
NetworkCredential networkCredential=new NetworkCredential();
networkCredential. UserName="abcd@gmail.com";
networkCredential. Password="123";
smtp. UseDefaultCredentials=true;
smtp. Credentials=networkCredential;
smtp. Port=587;
smtp. Send(mail);
ClientScript. RegisterStartupScript(GetType(), "alert", "alert('Message has been sent successfully.');", true);
}
要撰写电子邮件,我使用添加了texeditor的文本区域,然后将格式化后的文本分配给具有多行属性的ID为txtmessage
的文本框。但是我收到一条错误消息,说“此邮件没有内容”
有关上述说明,请参见下面的代码
<script type="text/javascript">
function myfun(){
var x=document.getElementById("area3").value;
document.getElementById("txtMessage").inner.HTML=x;
}
</script>
提前谢谢!
答案 0 :(得分:0)
检查以下代码行:
document.getElementById("txtMessage").inner.HTML=x;
您的“ txtMessage”应为<input>
,然后只需将其设置为value
document.getElementById("txtMessage").value=x;