我在Access數據庫中使用VBA函數來調用Lotus Notes以向客戶發送自動電子郵件。電子郵件正在從用戶個人Lotus帳戶發送,以便他們在已發送郵件中記錄已發送電子郵件的歷史記錄。但是,我不希望客戶看到我們的內部電子郵件地址。通過VBA發送時,在Lotus Notes中設置「From」電子郵件地址
我們正在指示客戶不要回覆電子郵件(而不是給我們打電話),並希望電子郵件看起來來自[email protected]。我能夠將'ReplyTo'字段設置爲像[email protected]這樣的東西,如果客戶回覆電子郵件但「發件人」字段仍然來自用戶的真實電子郵件地址並且客戶可以看到這些信息,並仍然發送電子郵件到我們的地址。
我已經嘗試設置以下屬性,但他們似乎並不工作:
.DisplaySent = "[email protected]"
.iNetFrom = "[email protected]"
.iNetPrincipal = "[email protected]"
(我現在有這些註釋掉在下面的VBA,因爲他們似乎沒有任何效果)
下面是我正在使用的VBA。有什麼建議麼? 謝謝!
Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient As Variant, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'THe current users notes mail database name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
'Next line only works with 5.x and above. Replace password with your password
'Session.Initialize ("password")
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string or using above password you can use other mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.principal = "[email protected]"
MailDoc.ReplyTo = "[email protected]"
'MailDoc.DisplaySent = "[email protected]"
'MailDoc.iNetFrom = "[email protected]"
'MailDoc.iNetPrincipal = "[email protected]"
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
MailDoc.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
感謝您的回覆。選項#1我不幸因內部原因無法完成。我正在考慮選項2,因爲不熟悉如何實現這一點。我們正在使用Domino服務器,但我不確定如何直接在服務器電子郵件框中創建電子郵件。是否有任何網上資源提供有關如何做到這一點的見解?我試着搜索,但我不確定我甚至在尋找什麼。 – user3644787
看看這裏http://stackoverflow.com/a/21900751/2065611 –
以前的URL非常有幫助。謝謝。我會嘗試一下併發布結果。 – user3644787