|
版主:下面这个我是从外网上找到的,需要工具-引用。
但我对172.16.232.236这个地址不明白,是我的主机地址?我换了以后运行到此出问题了,是NOTES的地址?我找不到,所以请您看看是怎么回事?
在VBA中用Lotus发邮件
Function AutoSend()
Dim Doc As Domino.NotesDocument
Dim Session As New Domino.NotesSession
Dim NotesDb As New Domino.NotesDatabase
Session.Initialize "1234" '密碼
Set NotesDb = Session.GetDatabase("172.16.232.236", "mail\py\weft_knit\pc\ptwf-knit-pc-6.nsf")
If NotesDb.IsOpen = False Then Exit Function
Msg = "請開啟以下附件"
vaRecipient = Array("wf-knit-pc-6@pacific-textiles.com", "wf-knit-pc-1@pacific-textiles.com")
vaFiles = Application.GetOpenFilename(FileFilter:="Excel Filer(*.xls),*.xls", _
Title:="E_Mail附件", MultiSelect:=True)
Set Doc = NotesDb.CreateDocument
With Doc
.ReplaceItemValue "Form", "Memo"
.ReplaceItemValue "SendTo", vaRecipient
.ReplaceItemValue "Subject", "自動發送的郵件"
.ReplaceItemValue "PostedDate", Now()
.ReplaceItemValue "Body", Msg
.ReplaceItemValue "$KeepPrivate", 1 '私件
'.ReplaceItemValue "ReplyTo", "Rockylee@3126.com"
'.ReplaceItemValue "Principal", "pc-19"
If IsArray(vaFiles) Then
With Doc.CreateRichTextItem("Attachment")
For i = 1 To UBound(vaFiles)
.EmbedObject 1454, "", vaFiles(i), "Attachment"
Next i
End With
End If
.Send True, vaRecipient
.Save True, False
End With
Set Doc = Nothing
Set NotesDb = Nothing
Set Session = Nothing
End Function |
|