???调用OUTLOOK发邮件的问题

fly001 2003-07-17 06:22:30
要自动写上标题,附件等内容。还有能不能判断用户是否点了“发送”按钮,最好给出详细的代码?各位大侠,先谢啦!
...全文
87 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ylm0101 2003-11-14
  • 打赏
  • 举报
回复
using System.Web.Mail;

private void BtnSend_ServerClick(object sender, System.EventArgs e)
{
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;
}
}
}
cyp503 2003-08-16
  • 打赏
  • 举报
回复
or:

<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
<%
MailMessage msgMail = new MailMessage();

msgMail.To = "christophw@sleeper.Dev.AlfaSierraPapa.Com";
msgMail.From = "webmaster@aspheute.com";
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");
%>

cyp503 2003-08-16
  • 打赏
  • 举报
回复
Sub SendMailOutlook(aTo, Subject, TextBody, aFrom)

'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

fly001 2003-07-18
  • 打赏
  • 举报
回复
怎么发附件啊?
xiongliang2003 2003-07-18
  • 打赏
  • 举报
回复
见 NET的 MailMessage 和SmptMail对象
孟子E章 2003-07-17
  • 打赏
  • 举报
回复
Private Sub SubmitButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("mailto:xx@ccc.com?body=cccc&subject=xxxx&cc=xxx@ddd.ddd")
End Sub

62,133

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧