Private Sub SubmitButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("mailto:[email protected]?body=cccc&subject=xxxx&[email protected]")
End Sub
Response.Redirect("mailto:[email protected]?body=cccc&subject=xxxx&[email protected]")
End Sub
'Create an Outlook object
Dim Outlook 'As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")
'Create e new message
Dim Message 'As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
'You can display the message To debug And see state
'.Display
.Subject = Subject
.Body = TextBody
'Set destination email address
.Recipients.Add (aTo)
'Set sender address If specified.
Const olOriginator = 0
If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
'Send the message
.Send
End With
End Sub
<% @Import Namespace="System.Web.Mail" %>
<%
MailMessage msgMail = new MailMessage();msgMail.To = "[email protected]";
msgMail.From = "[email protected]";
msgMail.Subject = "Attachment Test";msgMail.BodyFormat = MailFormat.Text;
msgMail.Body = "Check out the attachment!";
msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-report.pdf"));SmtpMail.Send(msgMail);Response.Write("Email was queued to disk");
%>
{
string strLevel="";
MailMessage mail=new MailMessage();
if(ToMan.Value.Trim()==""||Subject.Value.Trim()==""||Body.Value.Trim()=="")
{
return;
}
else
{
try
{
mail.From =FromMan.Value.Trim();
mail.To =ToMan.Value;
mail.Subject =Subject.Value;
mail.Body =Body.Value; strLevel=this.LevelSelect.SelectedItem.Value;
if(strLevel.Trim()=="NoImport") //Priority為尤先權
mail.Priority=MailPriority.Low;
if(strLevel.Trim()=="Import")
mail.Priority=MailPriority.High;
if(strLevel.Trim()=="Normal")
mail.Priority=MailPriority.Normal;
System.Web.Mail.SmtpMail.SmtpServer="192.168.0.158"; //Server service
mail.BodyFormat =System.Web.Mail.MailFormat.Text;
System.Web.Mail.SmtpMail.Send(mail); MessageShow("郵件發送成功");
RegisterClientOnLoadEvent(this,"CloseForm(true)");
}
catch
{
MessageShow("郵件發送失敗,可能信息是沒填寫完整,或服務器有問題");
}
finally
{
mail=null;
}
}
}