VBA中的Notes电子邮件文档中所有可用的字段是什么 [英] What are all the fields available in a Notes email document in VBA

查看:109
本文介绍了VBA中的Notes电子邮件文档中所有可用的字段是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了VBA代码以从组邮箱发送电子邮件.我设置了主体字段来说明邮件的来源.它几乎可以正常工作,将邮件放入组邮箱的已发送邮件中.即使我在Principal字段中有组邮箱名称,它仍然说它是发给我的.我发现无论哪个用户查看已发送邮件中的消息,都说该消息是由该用户发送的(这是一个动态字段).我想设置发件人"字段,发现可以用'.from =(User Name)"'这样的东西来实现.

I have written VBA code to send an email from a group mailbox. I set the principal field to say where the mail comes from. It almost works correctly, putting the message in the sent items of the group mailbox. Even though I have the group mailbox name in the Principal field, it still says it was sent my me. I discovered that whichever user looks at the message in sent items, it says it was sent by that user (it is a dynamic field). I want to set that From field, and I discovered I can do that with something like '.from = "(User Name)"'.

因此,我知道可用的基本变量,例如.SendTo,.CopyTo,.Principal,.From.但是我已经进行了网络搜索,无法弄清楚如何获得所有可用变量的完整列表.希望有人可以向我指出一些列出这些内容的文档?

So I am aware of the basic variables available, such as .SendTo, .CopyTo, .Principal, .From. But I have done web searches and I can't figure out how to get a comprehensive list of all the variables available. Hopefully someone can point me to some documentation that lists these?

供参考,这是我的代码:

For reference here is my code:

Function EmailFromNotes(strSendTo As String, strCopy As String, strSubject As String, _
    strText1 As String, strText2 As String, strText3 As String, _
    strText4 As String, strText5 As String, strAttachment As String, strFrom as String)

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Dim i As Integer

Dim AttachME As Object 'The attachment richtextfile object
Dim EmbedObj As Object 'The embedded object (Attachment)


    Set notessession = CreateObject("Notes.Notessession")

 ''''''''Group Mailbox'''''''''''''''''''''''''''''''''''''''''''''''''
    Set notesdb = notessession.GetDatabase("Servername", "mailin\GroupMailbox.nsf")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    'Open the mail database in notes
    If notesdb.IsOpen = True Then
    'Already open for mail
    Else
    notesdb.OPENMAIL
    End If

    Set notesdoc = notesdb.CreateDocument
    Call notesdoc.ReplaceItemValue("Subject", strSubject)
    Set notesrtf = notesdoc.CreateRichTextItem("body")
    Call notesrtf.AppendText(strText1 & vbCrLf & strText2 & vbCrLf & strText3 & vbCrLf & strText4 & vbCrLf & strText5)
    '''strCopy = "michael.thain@pnc.com"
    notesdoc.SendTo = strSendTo
    notesdoc.CopyTo = strCopy
    notesdoc.from = strFrom

''''''''Group Mailbox'''''''''''''''''''''''''''''''''''''''''''''''''
    notesdoc.principal = "Group Mailbox Name"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

If strAttachment = "" Then
Else
    Set AttachME = notesdoc.CreateRichTextItem(strAttachment)
    Set EmbedObj = AttachME.EmbedObject(1454, "", strAttachment)
End If

    Call notesdoc.Save(True, False)
    notesdoc.SaveMessageOnSend = True
    Call notesdoc.Send(False, strSendTo)
    Set notessession = Nothing

End Function

推荐答案

与许多其他邮件系统不同,Lotus Notes对欺骗发件人"字段持谨慎态度. NotesDocument.Send()方法不希望您这样做,它将覆盖您在其中放置的内容.提供了Principal字段,因此您可以说出您要代表的是谁,但是发件人应该是实际发件人的真实姓名.如果您查看已发送"文件夹中邮件的文档属性,相信您会发现发件人"字段确实包含您的姓名,而不是您的代码试图在该字段中输入的名称!

Unlike many other mail systems, Lotus Notes is finicky about spoofing the From field. The NotesDocument.Send() method doesn't want you to do it, and will override what you put in there. The Principal field is provided so you can say who you are sending on behalf of, but the From is supposed to be the true name of the actual sender. If you look at the document properties for the message in your Sent folder, I believe you'll find that the From field does indeed contain your name, not the name that your code is trying to put in that field!

至少在已发送"消息中,有一种解决方法.不必依赖SaveMesasageOnSend属性,而只需使用NotesDocument.Save()将文档直接写到组邮箱中,请确保设置了PostedDate而不是DeliveredDate,这样它将显示在已发送"视图中.但是,它将缺少Domino路由器通常会为您添加的其他字段,例如MessageID和其他一些字段-但这对您可能并不重要.该消息仍应可见.在任何情况下,无论是多么复杂,Memo表单中的字段中的公式及其在邮件模板中相关联的子表单都是您最终的指南,用于了解用户看到的内容与存储在邮件中的实际值之间的关系.文档.

There is a way around this, at least for the Sent message. Instead of relying on the SaveMesasageOnSend property, you can just use NotesDocument.Save() to write the document directly to the group mailbox, making sure that you set the PostedDate and not the DeliveredDate so that it will appear in the Sent view. It will be missing other fields that the Domino router would normally have added for you, though, like the MessageID and a few others -- but that might not be important for you. The message should still be viewable. In any case, as complex as it is, the formulas in the fields on the Memo form and its associated subforms in the mail template are your ultimate guide for figuring out how what the user sees is related to the actual values that are stored in the document.

如果您还担心确保收件人看不到您的名字,那么还有另一个窍门.它涉及将消息直接写入路由器邮箱(mail.box文件).但是,我已经看到一些系统,即使您执行此操作,也存在防止欺骗的代码,因此您必须尝试一下它是否可以工作.

If you're also concerned about making sure that recipients don't see your name, there's another trick. It involves directly writing the message to the router mailbox (the mail.box file). I've seen some systems, however, where there's code in place to prevent spoofing even if you do this, so it's something you'll have to try and see if it will work.

BTW:您是否在询问用户查看已发送"视图的索引时看到了什么?那应该在Principal字段中显示值.还是您在询问用户进入已发送"视图并打开消息时会看到什么?那应该显示Principal字段,后跟一个换行符,然后是From字段的"Sent by:". (请记住,由于我所描述的反欺骗规定,发件人"字段不太可能是您的代码设置的值.)这是否与您所看到的相符?

BTW: Are you asking about what the users see when they look at the index of the Sent view? That should be showing the value in the Principal field. Or are you asking about what the users see when go the Sent view and open the message? That should display the Principal field, followed by a newline and then "Sent by:" the From field. (Bear in mind that the From field is not likely the value that your code set due to the anti-spoofing provisions that I described.) Does this match what you are seeing?

这篇关于VBA中的Notes电子邮件文档中所有可用的字段是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆