你应该用MAPISession和Mapimessages这两个控件,在部件中加入
代码如下:
mapiSesson1.SignOn
With Mapimessages1
.MsgIndex = -1
.RecipDisplayName = "[email protected]"
.MsgSubject = "Title"
.AttachmentIndex = 0
.AttachmentPathName = "c:\test.txt"
.SessionID = mapiSesson1.SessionID
.Send
End With
mapiSesson1.SignOff
MsgBox "邮件发送完毕!", , "发送邮件"
代码如下:
mapiSesson1.SignOn
With Mapimessages1
.MsgIndex = -1
.RecipDisplayName = "[email protected]"
.MsgSubject = "Title"
.AttachmentIndex = 0
.AttachmentPathName = "c:\test.txt"
.SessionID = mapiSesson1.SessionID
.Send
End With
mapiSesson1.SignOff
MsgBox "邮件发送完毕!", , "发送邮件"
解决方案 »
- 大事件,大事件,VB爱好者们都进来
- 如何对目录中的文件或子目录进行排序?按时间或按大小?
- vb 恢复数据库 编译后无法运行
- winsock通信过程中断的问题
- 不怕你笑话,vb6中水晶报表例子这句代码CryRpt.ReportFileName = App.Path & "\sscx.rpt" 是啥意思?
- 建库的问题,有源码,欢迎测试!
- 数据库查询~~~~
- 在用VB做控件时可以用什么控件显示WORD文档?
- 请给一个win2k/xp下能杀掉别的进程的示例。
- 请问如何在vb的Collection对象中加入自定义的Type变量?
- 如果在VB中调用另外程序的菜单项
- 关于ADO记录集的问题!在线等待!!!!!
您可以通过Outlook Object Library中的MailItem对象的属性和方法添加附件,并生成新邮件,指定收件人、主题等信息,并发送,如下例:Private Sub Command1_Click()
NewMailWithAttachment
End Sub Sub NewMailWithAttachment()
' The Outlook object library needs to be referenced
Dim ol As Outlook.Application
Dim NewMessage As Outlook.MailItem
Dim myRecipient As Outlook.Recipient
Set ol = New Outlook.Application
' Create a new MailItem
Set NewMessage = ol.CreateItem(olMailItem)
' Embed a file into the new message
NewMessage.Attachments.Add "e:\fred.xls", olByValue
' Display the message
NewMessage.Subject = "testmessage"
Set myRecipient = NewMessage.Recipients.Add("Laura Jennings")
myRecipient.Type = olCC
NewMessage.Display
NewMessage.Send
End Sub