Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sending Lotus Notes Email from non-default database

Posted on 2003-11-05
7
Medium Priority
?
1,150 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

715 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