Solved

Sending Lotus Notes Email from non-default database

Posted on 2003-11-05
7
1,116 Views
Last Modified: 2012-06-27
I am using some code that sends an email via notes. The email always has my name as the sent from as i am logged onto my notes session. However, i also have another database in my workspace from which i can send messages using a different alias. How do i rewrite the code to send from the other database and not my default one.

I am guessing the code that needs to be changed is in either of these lines:

Set NotesDB = NotesSession.GETDATABASE("", "")
NotesMailDoc.FROM = NotesSession.UserName

I have tried specifying the datbase directly in the Set NotesDB line:
Set NotesDB = NotesSession.GETDATABASE("", "Mail\mailbox2.nsf") but it still gets sent from my 1st mailbox address.
0
Comment
Question by:Andystud
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:joekendall
ID: 9686244
What reference(s) do you have checked for working with Lotus Notes?
0
 

Author Comment

by:Andystud
ID: 9686299
don't think i have any. The references i have checked are:
Visual Basic for Applications
Access 9.0 object library
OLE Automation
ActiveX Data Objects 2.1
DAO 3.6
Excel 9.0
Office 9.0
0
 
LVL 11

Expert Comment

by:joekendall
ID: 9686394
If you are using Late Binding which it looks as though you are, you will not be able to do what you wish to do. You can only use the open database.

To check this out if you close Lotus Notes, can you send an email? You should not be able to.

If you want to choose the database, you will need to make a reference to the domobj.tlb Type Library and use it.

Joe
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:Andystud
ID: 9686429
so how do i choose a diferent database once i have referenced the Domino Objects library?
0
 
LVL 11

Expert Comment

by:joekendall
ID: 9686543
<code>

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Lotus Notes Procedures to Send Mail and Retrieve it.
'
'Joe Kendall 7/23/2002
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'This is a combination of a number of routines for sending an Notes Email
'from Visual Basic. This works on Notes 4.x and 5.x (at least up to 5.06a).
'Lotus Notes must be installed on the computer which will run this code.
'Parameters for the routine are:
'Subject : String - Can be a comma seperated list of addresses.
'Attachement : String - Can be a pipe (|) delimited list of fully qualified filenames
'BodyTest : String - Nothing to say, just a string as long as you like
'CC : String - Can be a comma seperated list of addresses. (Optional)
'BCC : String - Can be a comma seperated list of addresses. (Optional)
'SaveIt : Boolean - Set to True to save in the Sent Folder after sending (Optional)

'This is the only Procedure which I did not write.
'But I made many changes to it.
Public Sub SendNotesMail(Subject As String, Attachment As String, BodyText As String, SendTo As String, _
        Optional CC As String = "", Optional BCC As String = "", Optional SaveIt As Boolean = False)
    'Set up the objects required for Automation into lotus notes
    Dim db As NotesDatabase 'The mail database
    Dim dbDir As NotesDbDirectory 'The Notes DB Directory
    Dim UserName As String 'The current users notes name
    Dim doc As NotesDocument 'The mail document itself
    Dim AttachME As Object 'The attachment richtextfile object
    Dim session As NotesSession 'The notes session
    Dim EmbedObj As NotesEmbeddedObject 'The embedded object (Attachment)
    Dim aryAttachment As Variant
    Dim intAttach As Long
   
    'Start a session to notes
    Set session = New NotesSession
    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
    UserName = session.UserName
       
    'Open the mail database in notes
    Set dbDir = session.GetDbDirectory(session.UserName)
    Set db = dbDir.OpenMailDatabase
   
    If db.IsOpen = False Then
        db.OpenMail
    End If
   
    'Set up the new mail document
    Set doc = db.CreateDocument
   
    'The Split function is not working properly
    With doc
        'Change the Principal to reflect who you want the email to come from.
        'Obviously you can make it look as though it came from someone else.
        .AppendItemValue "Principal", "Bugs Bunny"
        .AppendItemValue "tmpDisplaySentBy", "Bugs Bunny"
        .AppendItemValue "From", "Bugs Bunny"
        .AppendItemValue "INetFrom", "Bugs Bunny"
        .AppendItemValue "Form", "Memo"
        .AppendItemValue "SendTo", Split(SendTo, ",")
        .AppendItemValue "CopyTo", CC 'Split(CC, ",")
        .AppendItemValue "BlindCopyTo", BCC 'Split(BCC, ",")
        .AppendItemValue "Subject", Subject
        .AppendItemValue "Body", BodyText
        .SaveMessageOnSend = SaveIt
       
       
    'Set up the embedded object and attachment and attach it
        If IsMissing(Attachment) = False Then
            If Attachment <> "" Then
                aryAttachment = Attachment 'Split(Attachment, "|")
                For intAttach = LBound(aryAttachment) To UBound(aryAttachment)
                    Set AttachME = .CreateRichTextItem("Attachment" & CStr(intAttach))
                    Set EmbedObj = AttachME.EmbedObject(1454, "", _
                        aryAttachment(intAttach), "Attachment" & CStr(intAttach))
                    .CreateRichTextItem ("Attachment" & CStr(intAttach))
                Next intAttach
            End If
        End If
    'Send the document
        'Gets the mail to appear in the sent items folder
        .AppendItemValue "PostedDate", Now()
        .Send False
    End With
   
    'Clean Up
    Set dbDir = Nothing
    Set db = Nothing
    Set doc = Nothing
    Set AttachME = Nothing
    Set session = Nothing
    Set EmbedObj = Nothing
End Sub

</code>

Joe
0
 

Author Comment

by:Andystud
ID: 9687023
I have added the .AppendItemValue lines to my existing code and it did send the message as if from another user, although my username was referenced in the sent by: field. Is there any way around this, or is it just how Notes handles the sending of messages?

Also, regarding the following lines of code.
         AppendItemValue "Principal", "Bugs Bunny"
        .AppendItemValue "tmpDisplaySentBy", "Bugs Bunny"
        .AppendItemValue "From", "Bugs Bunny"
        .AppendItemValue "INetFrom", "Bugs Bunny"
 
the bottom 3 lines appeared to have no effect. What are these used for?
0
 
LVL 11

Accepted Solution

by:
joekendall earned 125 total points
ID: 9687900
Sorry about the 3 lines. I was trying to change who it was from just as you want. It does not work that way. You can't seem to change it. If there is a way, I don't know how.

If you have another database, then you should be able to logon to that database and send your email as that user.

Joe
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now