Solved

Sending Lotus Notes Email from non-default database

Posted on 2003-11-05
7
1,124 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

821 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