Results 1 to 4 of 4
  1. #1
    g4tv4life is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    50

    Fixing a annoying Bug with Automatic Email through Lotus Notes

    Hello everyone, Been toiling away getting this code working to create and send emails through IBM Lotus Notes, and it works Perfectly!...



    Except for this one annoying damn thing.

    The code does everything EXCEPT close the email after it sends, which is a issue because if it batch sends 50 emails, that leaves 50 tabs to close which might even crash lotus as its such a P.O.S.

    Heres my code, does anyone know of a command to close the email after its sent?

    Code:
    Public Function Send_Email()
    
    
    'Complied Pro Publico Bono by DahulŪ
    
    
    Dim MyDB As DAO.Database
    Dim MyRS As DAO.Recordset
    Dim strSQL As String
    Dim Notes As Object
    Dim Maildb As Object
    Dim objNotesDocument As Object
    Dim objNotesField As Object
    Dim mysubject As String
    Dim mysendto As String
    Dim myBody As String
    strSQL = "Select * From [Police Departments Query];"
    
    
    Set MyDB = CurrentDb
    Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenDynaset)
    With MyRS
    .MoveFirst
    Do While Not MyRS.EOF
    mysubject = "Thank You Letter for Officer " & ![Officer Name]
    mysendto = ![Email] 'or you can use Me.txtemail for example
    'myBody =
    
    
    Set Notes = CreateObject("Notes.NotesSession")
    Set Maildb = Notes.GETDATABASE("", "")
    Call Maildb.OPENMAIL
    Set objNotesDocument = Maildb.createdocument
    Set objNotesField = objNotesDocument.appenditemvalue("Subject", mysubject)
    Set objNotesField = objNotesDocument.appenditemvalue("SendTo", mysendto)
    Set objNotesField = objNotesDocument.createrichtextitem("Body")
    Call objNotesDocument.REPLACEITEMVALUE("", , "Body", myBody)
    
    
    'here's the attaching bit
    
    
    objNotesField = objNotesField.EMBEDOBJECT(1454, "", [Path to PDF])
    
    
    Set Workspace = CreateObject("Notes.NotesUIWorkspace")
    Call Workspace.EDITDOCUMENT(True, objNotesDocument)
    
    
    Dim UIdoc As Object
    Set UIdoc = Workspace.CURRENTDOCUMENT
    Call UIdoc.GOTOFIELD("Body")
    Body1 = "Attached is a thank you letter for Officer " & ![Officer Name] & " for using a Automated External Defibrillator on " & ![Date of Incident] & ". Could you please see that the Officer gets it? Thank you."
    
    
    Call UIdoc.InsertText(Body1)
    
    
    'Insert some carriage returns at the end of the email
    Call UIdoc.InsertText(vbCrLf & vbCrLf)
    
    
    Call UIdoc.Send(False)
    
    
    Set session = Nothing
    .MoveNext
    Loop
    End With
    MyRS.Close
    Set MyRS = Nothing
    MsgBox "Emails have been Sent", vbOKOnly, "Operation Completed"
    End Function

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe objNotesDocument.Close ?

    What options do you have with intelisense for the document? I am going to guess this object is the one that represents the window you are referring to.

  3. #3
    g4tv4life is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    50
    Quote Originally Posted by ItsMe View Post
    Maybe objNotesDocument.Close ?

    What options do you have with intelisense for the document? I am going to guess this object is the one that represents the window you are referring to.

    That put me on the right tract, turned out to be UIdoc.Close

    tossed that at the end and it works perfectly, now off to fix my other bugs. Thanks

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Glad you were able to work through it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 19
    Last Post: 10-26-2012, 11:33 AM
  2. Lotus Notes Automation
    By manic in forum Programming
    Replies: 10
    Last Post: 03-30-2012, 02:55 PM
  3. Replies: 3
    Last Post: 03-08-2012, 04:43 PM
  4. Replies: 0
    Last Post: 08-20-2010, 09:26 AM
  5. Import Lotus Notes address book into a MS Access table.
    By acheo in forum Import/Export Data
    Replies: 0
    Last Post: 02-19-2007, 02:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums