sorry Bosman, the call for "Principal" has nothing to do with the mail DB being used. It simply changes the "Name" the email appears to come from.
Main Topics
Browse All TopicsHi All,
I am using some code originally posted by Bill Hanson for sending HTML emails through lotus notes. Posted here: http://www.experts-exchang
..and thank you very much Bill it has provided some functionality long missing from my systems.
Previously I had been using some avilable code that I'd fine tuned for just plain text emails....
Two questions then:
a) I find with this code that I am unable to set the "Principal" with the email. Generally I had been able to say set say (MailDoc.Principal = "Frederick Von Harpen") in the mail code and so when the mail was sent, it would appear to come from good ol frederick. Setting [Call doc.ReplaceItemValue ("Principal","Frederick Von Harpen")]is ineffectual on this code and I'm not really sure why....it should work the same as does CopyTo, BlindCopyTo, RepyTo etc...all of which work, except "Principal"
b) I would like to be able to send the mail through a specified mail database. The code just grabs your default mail DB for sending the mail, but here in the office we have lotus notes open with our own mail, and common shared mailboxes. How would I modify the code to select a specific mailbox?
I am not overly proficient in VB so please be kind in your responces as I am likely to simply copy paste and test :)
Cheers
DeZZar
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I know. It normally works, but I don't know why it doesn't work here.
What you want with the mail database I don't understand. At the moment, you don't really use the database: the code needs "some" database to create a document in, but that's all, since the document isn't saved. In fact, you could have used ANY database. So what do you want exactly with the mailin database??
Using Lotus Notes I have my own mail database - which is for my own personal email. call the database DeZZar82.nsf....this is an inbox, sent items, folders etc....
The code above (and all the lotus email code I've used in the past) simply uses your 'default' mail database to send the email created by the code.
However, within my lotus notes program I can not only use my own mail database...the DeZZar82 mail in database (say for arguments sake email address dezzar82@mycompany.com) but also other databases that I have access to (say CompanyEnquiries@company.c
So the code above doesn't have a way to specify that I do not want mail sent using DeZZar82 as the mail database, but rather 'CompanyEnquiries' instead.
Don't confuse the two portions of my question. One doesn't relate to the other. "Principal" is just a setting to let you change the 'name' the mail appears to come from. Using other mail code I have I can specify "Principal" as Mikey Mouse and so when you recieve an email from my database it will come from "Mikey Mouse" it will still however have used the 'default' lotus mail database to send the mail....(DeZZar82)
No, sorry, it doesn't work like that in Notes, that is to say: I sense a misconception about the mail database that you use. Which is: you DON'T really use any database at all. All the code does is, basically: an in-memory NotesDocument object is created, the object is filled and sent away, and then it is destroyed! The object is not saved to disk. Hence, you could have created that very same object in ANY database, because you don't use a form, you don't use fields, or any property or method that requires a document saved to disk. Setting doc.Form= "Memo" is just an assignment, nothing else. It means in this case that the receiving end will recognise which form should be used to open the document received. That's all.
That's why I asked my question: where does a mail-in database come in??
it is a given that you know alot more about notes than I do so I apologise for any mis-understandings.
I'll attach the code I have been using in the past to simply construct plain text emails and perhaps this might shed some light on where I am coming from.
In the code above, if I change the line:
doc.SaveMessageOnSend
the email being sent will be saved in the sent items of (DeZZar82@company.com) the mail file I am refering to as my default mail database and any recieving the mail will see that it has come from Dezzar82@company.com and when they hit reply it will go back to DeZZar82@company.com.
It would not matter if my lotus notes had 4 different mail databases open (all sending and recieving mail on my machine):
(dezzar82@company
The code would still manage to save in the sent item in the mail database that hosts dezzar82@company.com
In the code below the line "Set Maildb = Session.GetDatabase ("",MailDbName) seems to cleary point to the fact I could, if I knew how, set up the code to use say (enquiries@company.com) as the mail database instead of my own (my default) dezzar82.
I guess I am looking for some information on how this can be controlled and how it might be integrated into the code above that uses mime for sending html email instead of the method employed by the code below.
just something to add to this, if I close my own default email within notes and simply leave one of the other inboxes open. When the original code posted runs, it still manages to use my 'closed' mail file as the the place to save the sent item and the recipient of the email still sees it as coming from me "dezzar82" reply automatically selects Dezzar82 as the place to submit a reply the message
Based on what you said regarding the fact the code doesn't use a mail faile as such I would then expect the recipient to recieve the mail from some undefined name and when the hit reply it would have a blank email address as it wouldn't know "where" the email came from....?
So the comment that the system isn't using a mailfilemailin databse (whatever you want to call it) to send the email doesn't make any sense...
and if it is supposed to just use whatever mail database is open on your machine, it doesn't explain why, when my own mail file is closed and I only have another common inbox open, that it has still used my mail file as the effective sender...
Setting
doc.SaveMessageOnSend = True
changes everything, because its effect will be that the document is saved in the database it was created in. If that's what you want to happen, and you want it to be a different mail database, change
Set Maildb = Session.GetDatabase("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
into
Set Maildb = Session.GetDatabase("your server", "mail/somemaildatabase.nsf
If Not Maildb.IsOpenThen
MsgBox "Cannot open mail database"
Exit Sub
End If
That snippet would open a specific database on a specific server, which is probably what you need. The person who runs your code would obviously need sufficient access rights to create the mail (Author rights will do).
Assuming that you set SaveMessageOnSend to True,
> if I close my own default email within notes and simply
> leave one of the other inboxes open.
The code runs in the background, and has nothing to do with the foreground Notes client activities.
> When the original code posted runs, it still manages
> to use my 'closed' mail file as the the place to save
>the sent item
Correct. This happens because the OpenMail method specifically opens the current user's mail database.
> and the recipient of the email still sees it as coming
> from me "dezzar82" reply automatically selects Dezzar82
> as the place to submit a reply the message
Ah, no, not true. There is a difference between the mail database and the current user. The current user sends the mail, so his return address will be used in the mail, irrespective of the mail database the mail will be stored in.
So there are 2 things very important:
- the current user: when a mail is sent through the Domino server, it is sent in his/her name with the right reply address
- the NotesDatabase object: when the document is saved (which is not required for mail to work), it is saved in the database in which the NotesDocument object was created
Sorry for any misunderstandings, I might have misunderstood you. Hope this clears it up a bit.
thanks sjef it seems we're both on the same page now.
So the second snipet of code I posted is not the one I want to change the mail file on....it is the original one posted by Bill Hanson for using MIME to send HTML email.
I don't see the same: Set Maildb = Session.GetDatabase("", MailDbName)
in his code and so I don't know where to start to achieve this. It seems to only call on notes with the following:
Set sess = CreateObject("Lotus.NotesS
sess.Initialize ("nag1999")
You may also notice that the second set of code I posted (the plain text one) doesn't require a password to be set - it just uses the open mail file - Bill Hansons code specifically calls for the password and if you leave it out your presented with a Notes message asking for a password before the message will send. Is there any way to avoid this.
Effectively, can the original code posted be modified to work more like the second code posted in regards to setting the mail file, changing the "principal" and functioning through an open lotus notes sessions without asking for passwords etc...
You help is greatly appreciated!
Cheers
DeZZar
ok.....looks like I've done it. Thanks for the tips, it pointed me in the right directio.
I have changed:
MailServer = sess.GetEnvironmentString(
MailFile = sess.GetEnvironmentString(
Set db = sess.GetDatabase(MailServe
to just:
Set db = sess.GetDatabase("SERVER/N
and I am able to connect to any database to 'save' the message in sent items.
I am still however frustrated with:
Call doc.ReplaceItemValue("Prin
In order to achieve the desired effect I MUST be able to change the 'Name' the email is coming from. I can set ReplyTo in the same manner without issue. And can set Principal in other notes email code.
Any help as to why it wont work with this code would be greatly appreciated!
Sorry, but you're exactly right. Just a small remark: instead of
Set db = sess.GetDatabase("SERVER/N
it's better to use
Set db = sess.GetDatabase("SERVER/N
The last parameter indicates whether you want the database to be created on the server if it doesn't exist. Which you don't want, I assume.
As for John Smith: is there a John Smith in the company, and in the server's Name and Address book? Otherwise it won't work. But let's assume there is.
Can you look in the saved mail if there is a field called Principal? In the view, click right on the mail, then click on Document Properties. On the 2nd tab, you'll see all fields (called Items actually) in the document. Does Principal have the correct value? Do the same for the received mail (send one to yourself). What do you see?
By the way, if this is an agent, you CAN change the sender's name: ask your admin to create an additional notes-ID for a fake person, and ask him to sign the agent using that ID. To prevent asking the admin over and over again to re-sign the agent, when you applied changes to it, you can put the real code in a script library, which you call from the agent.
So in the agent's Initialize, you only have
Use "Agents"
Call SendMailAgent
and in a scriptlibrary called "Agents" you put all the code, starting with
Sub SendMailAgent
...
End Sub
thanks sjef, I will check the principal settings when I'm back at work on monday.
What I find a little strage though is that, with the second set of code I posted above (the full script for just sending plain text emails) I can literally set "Principal" to whatever I want. I could put "MailDoc.Principal = "Slap My Forehead" and it will work, people will be getting mail from "Slap My Forehead" obviously without 'Slap My Forehead' ever actually being found anywhere in any system/address book or otherwise...
If your having trouble believing me, try the code.
So based on this, I'm not seeing any relevant connection between the setting of "Princpal" which appears to me to be simply a setting to amend the display name..(?) and the actual existance of the name a user on the servers....?
Could be, I believe you. I suppose, what should happen is that Domino retrieves the user you mention in the Principal field, fetches his or her mail address, and posts it to the other side. Anyway, that's what I am led to believe.
Setting Principal seems to need to be handled differently with MIME:
http://www-10.lotus.com/ld
OK well to date there is still no solution to setting the "Principal" or for all intensive purposes the "From Name" on the emails being sent with this code.
I checked the property settings on the actual emails and strangely enough, emails issued with this code do not contain "Principal" in the mail settings, instead the available settings are: (in part)
- AltFrom
- DisplayFrom
- DisplayFrom_Preview
- From
All of which are in-effectual on the actual name displayed. Some of these settings are indeed changed by the code when sending the email (becuase they have the value set in the code when checked) but don't actually change the from name displayed.
The thread contained in the link above might provide clues to someone who knows Mime inside out, but for me it basically just shows someone had the same issue and then suddenly figured it out without bother to share the result.
So I will close this thread and live with this issue for a while longer, maybe revisit with a new thread soon.
Cheers
DeZZar.
How disappointing...
Last attempt: can you also set the InetFrom-field, to the Internet reply address of the principal?
http://www.josephhoetzl.co
Business Accounts
Answer for Membership
by: sjef_bosmanPosted on 2009-10-08 at 01:58:19ID: 25523263
To me, the line with cipal","Jo hn Smith") cipal","Jo hn Smith/OU/Acme")
Call doc.ReplaceItemValue("Prin
seems completely legit. If you have 2 John Smiths at your company, you'd better use the complete hierarchical name, like
Call doc.ReplaceItemValue("Prin
> How would I modify the code to select a specific mailbox?
What exactly do you mean by that? Do you want the mail saved, in a specific mail database? To do that, you open that mail database and set SaveMessageOnSend to True.