Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controling Notes via VBA?

Status
Not open for further replies.

Kretzer

Technical User
Nov 6, 2002
37
NL
Hi,

concerning Lotus Notes 5.
What is working so far:

We can create emails out of MS Access and send them using Lotus Notes, attach attachments and so on.

What is not working :

We would like to change the email address of the sender. So we want to create an extra email postbox for maybe 5 people who will work with this database. All emails, sent by these people should be sent from one email adress and not from the email adress of the current person.

Does anyone have an idea how this can be done?

Thank you

Martin
 
Traditionally, the Notes answer is to create an ID that goes with the mailbox, and either have the users switch ID when they deal with that mailbox, or code an agent to send the mail. The agent can be set to work on behalf of a given ID.

Pascal.
 
Hi Pascal,

thanky for your efforts. Unluckily i do not hav any experiences in programming Notes. My aim is to realise this email thing from Access via VBA.

So it would help me a lot more if you would have any kind of code example for me.

Yesterday I tried a lot and was quite frustrated. I found out that the Notes object I use in VBA also has got the "from" property. But the thing is that this property is not going to work correctly.

Once I send an email using:
Code:
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String '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)
Dim workspace As Object ' frontend class to display to user
    
'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")
    
'Get the sessions username and then calculate the mail file name
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.Form = "Memo"
 MailDoc.SendTo = Recipient
 MailDoc.Subject = Subject
 MailDoc.Body = Bodytext
 MailDoc.From = "mailbox@ourplace.com"
 MailDoc.CopyTo = CC
 MailDoc.SAVEMESSAGEONSEND = SaveIt
                
'Send the document
 MailDoc.SEND 0, Recipient
the everything works allright.
In my sent box (in notes) the email sender is "mailbox@ourplace.com" BUT the receipient will see my proper email instead. So the maildoc.from property is just working for myself in my own sent mailbox! This seems quite useless to me!

maybe you have an idea?

thank you in advance...

Martin


 
The From field is indeed set by the server - to avoid mail spoofing. If anyone could send mail under anyone else's name, it would be chaos, would it not ?
Therefor, you have to justify that you are sending mail as the person you wish to be. Given that you are taking the current user name from the Notes session, it follows that the server is deciding that it is that user that is sending the mail.
As I said above, you need a Notes ID that is named as the user you wish to send from. That is an administrative question, not a programming question. Once you have that ID, you can switch to that one and use your code as it is.

Pascal.
 
I agree with pmonett, ask to your notes administrator to give you that special ID. After that you could swith from one user to another and send mails from the "new user".
 
Alright,

I think I still don't get it right.

Once more the situation here:
There is an Access DB.
Approxiamately 5 people will work with this Database.
A Function of this DB is to send emails.
What I can do so far is send emails, attach files and so on
BUT: the when the receipient ansers this email he will answer directly to the sending person.

What we would like to have is:
When the receipient answers he answers to a special mailbox which is only designed for mails which are answering emails for this DB.

How to do this (what I've learned so far from you):
Our special email inbox has got an ID.
When sending emails from Access I do have to switch from the normal User Account to the specail mailbox Account using this ID.
And when the reciepient answers this email he will not answer the person but to the special mailbox.

Question marks:
- How to get these mailbox ID's? (Is it just the Admisnistrator who knows about it or is there a value, a variable which I can read from Access?)

- How to switch mailboxes? Which statement would do this? Any FAQ Page, Help Text, Example?

And once more.
Thank you for your help.

Martin
 
Your Notes admin will indeed be able to give you the ID file for the mailbox.

As for how you switch mailboxes, I can only ask how do your users identify themselves and send mail in the first place ?
I mean, if they are authenticated to Access and send mail via their proper Notes identity, then switching is just a process of logging on with a different account, is it not ?

Pascal.
 
Hi,

I found the solution it is as that simple...
Instead using

Code:
maildoc.from "emailadress"

you simply have to use

Code:
maildoc.principal "emailadress"

That's it.
Thank you anyway.
Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top