通过Outlook2007发送邮件 [英] send mail thru outlook2007
本文介绍了通过Outlook2007发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过Outlook2007发送电子邮件?
how can i send an email thru outlook2007
推荐答案
本示例说明如何使用VB.Net将电子邮件添加到Microsoft Outlook发件箱.在这里获得此工作的方法是添加对"Microsoft Outlook对象库"的引用(在项目上单击鼠标右键-添加引用-选择"COM"选项卡-选择"Microsoft Outlook对象库".
This example shows how to add e-mail to Microsoft Outlook outbox using VB.Net .The most improtant point here to get this working is to add a reference to "Microsoft Outlook object library"(Right click on the project -Add References - Select the COM tab - Select "Microsoft Outlook object library".
Public Class Form1
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
If (txtTo.Text.Length > 0 And txtSubject.Text.Length > 0 And txtBody.Text.Length > 0) Then
Try
Dim ol As New Outlook.Application()
Dim ns As Outlook.NameSpace
Dim fdMail As Outlook.MAPIFolder
ns = ol.GetNamespace("MAPI")
ns.Logon(, , True, True)
‘creating a new MailItem object
Dim newMail As Outlook.MailItem
‘gets defaultfolder for my Outlook Outbox
fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
‘assign values to the newMail MailItem
newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
newMail.Subject = txtSubject.Text
newMail.Body = txtBody.Text
newMail.To = txtTo.Text
newMail.SaveSentMessageFolder = fdMail
newMail.Send()
Catch ex As Exception
Throw ex
End Try
End If
End Sub
End Class
这篇关于通过Outlook2007发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文