• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 493
  • Last Modified:

[VBA] Send e-mail from shared account

I'm writing an Access application, which generates Word documents with an average of 10 concurrent users. This attachments should be mailed using Lotus Notes from a shared account, which I will call the Desk account from here.

My problem is that I cannot find the reason why the e-mail I send, is send on my name, instead of the name of the Desk account. I hope anyone here has experience with sending e-mail from a general (shared) account on the network and can provide me example-code.

Below is the code I use to create an e-mailitem on the server:

Public Function LotusNotesEmail(strTo As String, strCC As String, strSubject As String, strBody As String, Optional strAttachmentPath As String)

Dim objNotesSession As Object
Dim objNotesDatabase As Object
Dim objNotesNewMail As Object
Dim objRichTextItem As Object

'Create a Lotus Notes Session and open the user database
Set objNotesSession = CreateObject("Notes.NotesSession")
Set objNotesDatabase = objNotesSession.GetDatabase("Mailin\dskmrgbw.nsf", "")

'Check if Lotus Notes is open already
If objNotesDatabase.IsOpen = False Then
    objNotesDatabase.OpenMail
End If

'Create a new mail and set the properties
Set objNotesNewMail = objNotesDatabase.CreateDocument
With objNotesNewMail
    .Form = "Memo"
    .SendTo = strTo
    .CopyTo = strCC
    .Subject = strSubject
    .Body = strBody
    .SaveMessageOnSend = True
End With

'If there is an attachment specified, than attach it (embedded) in the new mail
If (strAttachmentPath = "" Or strAttachmentPath = vbNullString) = False Then
    Call objNotesNewMail.EmbedObject(1454, "", strAttachmentPath)
End If

'Send the new mail
objNotesNewMail.PostedDate = Now()
Call objNotesNewMail.Send(False)

'Clean up all objects
Set objNotesSession = Nothing
Set objNotesDatabase = Nothing
Set objNotesNewMail = Nothing
Set objRichTextItem = Nothing

End Function
0
Jochem
Asked:
Jochem
  • 2
1 Solution
 
ZvonkoSystems architectCommented:
Your question is a common problem.
Notes prevent you changing the From item in a mail.
But it offers one additional item name Principal for adjusting the From field visible by recipient.

And you have to know that last saving designer is the owner of an agent and so all mails are sent on below his/her name.

For this field Principal you have to do it like this:
With objNotesNewMail
   .Form = "Memo"
   .Principal = strPricipal
   .SendTo = strTo
   .CopyTo = strCC
   .Subject = strSubject
   .Body = strBody
   .SaveMessageOnSend = True
End With


Where the string strPrincipal could be something like this:
   "Zvonko Paunosk@EE"

or:
   "zvonko.paunoski@mysite.de"

Good luck,
Zvonko


0
 
JochemAuthor Commented:
Tnx Zvonko, you really helped me!
It's strange that this property is not know in the API of both Lotus and Domino. Point are for you.

A mistake in the code above, causes that the sent message was stored in the local folder of the sender. This has to be set to the following:

'GetDatabase(Servername, MailDatabasename)
Set objNotesDatabase = objNotesSession.GetDatabase("", "Mailin\dskmrgbw.nsf")

Greetings,


Jochem
0
 
ZvonkoSystems architectCommented:
Thanks for the points :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now