Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending Lotus Notes Email from non-default database

Posted on 2003-11-05
7
Medium Priority
?
1,161 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

886 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