如何通过IBM Notes决定是否保存电子邮件? [英] How can I decide whether to save or not save an email via IBM Notes?
本文介绍了如何通过IBM Notes决定是否保存电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用以下代码通过IBM Notes发送电子邮件。一切正常,但我想不出如何不将电子邮件保存在文件夹&Sent&Quot;中。
我已经尝试将行
.PostedDate = Now()
在&objBackendDocument";对象,并尝试清除该值,因为我在一些帖子中看到,这可能是IBM Notes将电子邮件保存在";Sent";文件夹中的条件。但没有奏效。
如果我使用替代邮件文件,它根本不会保存我的电子邮件。如果我使用我的标准邮件文件,它会忽略&blnSaveEmail;保存所有电子邮件。
我不想保存电子邮件,因为我想自动发送带有附件的电子邮件,这些附件已在用户PC上(节省存储空间并避免副本)。
另一个想法可能是去掉最近发送的电子邮件中的附件,但目前这对我来说很困难。因为我仍在尝试理解IBM Notes的API是如何工作的。:)
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'+
'+ EMail_by_Notes
'+
'+ API: Lotus Notes COM/OLE
'+ Parameter "varRecipients": Requires a VARIANT or an array (VARIANT) of verified email-adresses
'+ Parameter "strSubject": Requires a STRING as the title of the email
'+ Paramater "strMessage": Requires as STRING as the content of the email
'+ Parameter "varCopy" optional: VARIANT or an array (VARIANT) of verified email-adresses
'+ Parameter "varBlindCopy" optional: VARIANT or an array (VARIANT) of verified email-adresses
'+ Parameter "varAttachements" optional: VARIANT or an array (VARIANT) of filepath(s)
'+ Parameter "blnSendImmediately" optional: BOOLEAN
'+ Parameter "blnSaveEMail" optional: BOOLEAN
'+ Parameter "strAlternative_Mailfile" optional: STRING, contains the filename of the alternative mailfile
'+
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function EMail_by_Notes( _
varRecipients As Variant, _
strSubject As String, _
strMessage As String, _
Optional varCopy As Variant = "", _
Optional varBlindCopy As Variant = "", _
Optional varAttachements As Variant, _
Optional blnSendImmediately As Boolean, _
Optional blnSaveEMail As Boolean, _
Optional strAlternative_Mailfile As String _
)
Dim objNotesSession As Object
Dim objNotesWorkspace As Object
Dim objNotesDatabase As Object
Dim objBackendDocument As Object
Dim objFrontendDocument As Object
Dim objRecipients As Object
Dim objCopy As Object
Dim objBlindCopy As Object
Dim objSubject As Object
Dim objEmbedded As Object
Dim objAttachement As Object
Dim strMailServer As String
Dim strMailFile As String
Dim strFilepath As String
Dim lngIndex As Long
'Starts Notes Session
Set objNotesSession = CreateObject("Notes.NotesSession")
'Locate the mailserver
strMailServer = objNotesSession.GetEnvironmentString("MailServer", True)
'Check for an alternative mailfile (in case you have a second account)
If VBA.Len(strAlternative_Mailfile) = 0 Then
'Uses the standard account
strMailFile = objNotesSession.GetEnvironmentString("MailFile", True)
Else
'Uses an alternative mailfile, if the filename is wrong, it uses the standard account
'Unfortunately there is no error message
strMailFile = "mail/" & strAlternative_Mailfile
End If
'Connect to the database
Set objNotesDatabase = objNotesSession.GETDATABASE(strMailServer, strMailFile)
'If your constructed path (variable strMailFile) is wrong or the database cannot be accessed
'then this line will make sure to fallback to the mailfile configured in your location document in Notes Client.
If Not objNotesDatabase.IsOpen Then objNotesDatabase.OPENMAIL
'Create a Notes document in the backend
Set objBackendDocument = objNotesDatabase.CREATEDOCUMENT
With objBackendDocument
'Fill in the contents
Set objRecipients = .APPENDITEMVALUE("SendTo", varRecipients)
Set objCopy = .APPENDITEMVALUE("CopyTo", varCopy)
Set objBlindCopy = .APPENDITEMVALUE("BlindCopyTo", varBlindCopy)
Set objSubject = .APPENDITEMVALUE("Subject", strSubject)
'Attach the file(s)
If VBA.IsArray(varAttachements) = True Then
For lngIndex = LBound(varAttachements) To UBound(varAttachements)
strFilepath = varAttachements(lngIndex)
If strFilepath <> "" And VBA.Dir(strFilepath) <> "" Then
Set objAttachement = .CREATERICHTEXTITEM("Attachment" & lngIndex)
Set objEmbedded = _
objAttachement.EMBEDOBJECT(1454, "", strFilepath, "Attachment" & lngIndex)
End If
Next
ElseIf VBA.Len(varAttachements) > 0 And VBA.Dir(varAttachements) <> "" Then
Set objAttachement = .CREATERICHTEXTITEM("Attachment1")
Set objEmbedded = _
objAttachement.EMBEDOBJECT(1454, "", varAttachements, "Attachment1")
End If
'Save or do not save the email in the folder "sent"
.SAVEMESSAGEONSEND = blnSaveEMail
End With
'Load Notes Workspace
Set objNotesWorkspace = CreateObject("Notes.NotesUIWorkspace")
'Get the backend document in the foreground
'Also in case, the email shall be edited before sending it
Set objFrontendDocument = objNotesWorkspace.EDITDOCUMENT(True, objBackendDocument)
With objFrontendDocument
'Fill in the emails message
'Important if you use a signature in IBM Notes
.GoToField "Body"
.InsertText strMessage
'Check, whether the email shall be sent immediately or not
If blnSendImmediately = True Then
'Send the email
.Send
'Disable prompt for saving in IBM Notes
.Document.ReplaceItemValue "SaveOptions", 0
'Close the document
.Close
End If
End With
End Function
推荐答案
您正在执行的操作:
- 生成文档%1
- 处理doc1.uidocument
- 发送doc1.uidocument.document(=doc2)
Send适用于doc1,而不是uidoc或doc2。
此外,在UI中打开并在后台发送也没有意义。
您应该在后台执行所有操作(在其配置文件中查找用户签名)。 如果您想要与用户交互,请在前台打开,让他工作并选择保存或不保存邮件(这是全局Notes客户端首选项,可以通过字段MailSaveOptions进行更改)这篇关于如何通过IBM Notes决定是否保存电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文