Solved

Sending Lotus Notes Email from non-default database

Posted on 2003-11-05
7
1,141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

636 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