0

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

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

以下是我的代码供参考:

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
4

3 回答 3

3

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!

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.

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: 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?

于 2013-06-10T19:19:06.943 回答
0

邮件字段通常由 RFC 为所有邮件定义。 http://en.wikipedia.org/wiki/Email#Message_header RFC 5322 https://www.rfc-editor.org/rfc/rfc5322

于 2014-01-31T13:50:45.987 回答
0

在 RFC 5322 标准中,From 字段的用途与 Lotus Notes 中的不同,因为它始终标识 mail.box 的所有者。不是使用字段 Principal 来标识写入电子邮件的邮箱的所有者,而是使用字段 Sender 来标识生成电子邮件的有效用户。许多电子邮件提供商在电子邮件标头中不接受(或者更好地说不再)字段 Principal ,并且由于不符合 RFC 5322 而被退回。在由 LotusScript 直接在 mail.box 中保存的文档中生成的消息中,您应该使用字段 From 而不是字段 Principal 并添加字段 Sender 作为有效发件人(发送者)的电子邮件地址,他在常规 Lotus电子邮件将位于“发件人”字段中。

于 2016-04-14T06:30:03.250 回答