请教高手,我编写了一个简单的script,希望能够将指定目录下的邮件 forword到我指定的外部邮箱中。
代码如下
Sub Initialize
Dim s As NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim maildoc As notesdocument
Set s=New notessession
Set db = s.CurrentDatabase
Set view = db.GetView( "old" ) '在名为 “old”的目录下查找邮件
Set doc = view.GetFirstDocument '取第一个邮件
While Not doc Is Nothing
Set maildoc=New NotesDocument(db) '这里的 maildoc 表示邮件文档
maildoc.form= "memo "
Call doc.CopyAllItems(Maildoc,True)
maildoc.sendto="[email protected]" '设置你要存放的邮件地址
Print doc.sendto(0)
maildoc.copyto=""
'如果你对是否有发送成功没有信心,可以开打下面的代码
'这样发送出去的邮件还会在已发送邮件中保存一份
'maildoc.SaveMessageOnSend = saveit
'Call maildoc.Send(True)
Set doc = view.GetnextDocument(doc)
Print "发送成功! "
Wend
End Sub
运行之后出现2个问题:
1.出现提示“You hace requested to sign this Internet message,but your current ID
does not contain or does not specify an Internet certificate for signing. Select
OK to send the message anyway. Select Cancel to not send the message”
选择OK后才能正常发送出去。
2.我的邮箱收到的邮件是以原来发件人的名义发送的。比如说 [email protected] 给我发了一封邮件,
我收到之后用上面的程序转发之后,我xxx邮箱中收到的发件人是 [email protected]
------解决方案--------------------
你CopyAllItems这个把发件人的信息都带过去了,所以收到的时候显示的是原来的发件人。
可以这样
set MailDoc as new NotesDocument(db)
dim body as new notesrichtextitem(MailDoc, "body")
call doc.RenderToRTItem(body) '这个可以把原来的邮件Render到新邮件的body域中。
然后再设置新的收件人就可以了。
------解决方案--------------------
docMail.removeItem("Encrypt")
docMail.removeItem("Sign")