您的批评和鼓励都是我把编程无限办好的动力! 您编程时遇到困难,或遇到不顺心的事想发发牢骚尽管到这里来吧! 虽然本网力求全面,但也不能包罗万象,这些我筛选出的优秀网站连接就是对本站最好的补充! 学习编程当然也离不开书本了,这里收集大量编程书籍! 编程无限之源码超市,这里收集的代码令你意想不到的全面! 欢迎光临编程网校,这里专门收集VB/CB入门文章及技术文章! 欢迎光临编程无限!
     
       
 
当前位置:英文资料 >> NetWork
Send Mail from Visual Basic Using OLE Messaging
  资料类型: NetWork 上传时间: 2001-02-21 阅读次数: 2392



' 1) Open a new project in Visual Basic.
' 2) On the Tools menu, choose References and select the Microsoft CDO 1.21 Library.
' 3) Add a CommandButton to the default form. Accept the default name, Command1.
' 4) Copy the following code into the General Declarations section of the default form:


Option Explicit


Private Sub Command1_Click()
Dim objSession As Object
Dim objMessage As Object
Dim objRecipient As Object


'Create the Session Object
Set objSession = CreateObject("mapi.session")


'Logon using the session object
'Specify a valid profile name if you want to
'Avoid the logon dialog box
objSession.Logon profileName:="MS Exchange Settings"


'Add a new message object to the OutBox
Set objMessage = objSession.Outbox.Messages.Add


'Set the properties of the message object
objMessage.subject = "This is a test."
objMessage.Text = "This is the message text."


'Add a recipient object to the objMessage.Recipients collection
Set objRecipient = objMessage.Recipients.Add


'Set the properties of the recipient object
objRecipient.Name = "John Doe" '<---Replace this with a valid
'display name or e-mail alias
objRecipient.Type = mapiTo
objRecipient.Resolve

'Send the message
objMessage.Send showDialog:=False
MsgBox "Message sent successfully!"

'Logoff using the session object
objSession.Logoff
End Sub

推荐给朋友 点 评( 0 ) 返回前页 关闭此页
   
  本类最热文章排名:
  1.Find IP address ginving the hostname
2.Get the Name of the ...
3.This function return...
4.Use this to send an email to somebody
5.Disconnect from a di...
6.Terminate all the active RAS Connections
7.How to ping an IP address using VB
8.Sending A File Via The XModem
9.Dialing A Phone
10.How to load the defa...
   
   
  评论:
 
 
 

 

关于本站 版权声明 联系方法
编程无限 V4.1 Copyright © 1999-2008 21code.com

京ICP备05006938号