none
MailItem.Display gives Automation object error on Lotusscipt RRS feed

  • Question

  • Hi,

    I've been trying to automate creation of new Outlook mail from Lotus Notes.

    My problem is MailItem.Display() gives Automation object error - it displays the new mail window then gives the error.

    If I use MailItem.Display(True) there is no error if I send the newly created mail.

    But it gives an error if I close the new mail window without sending it.

    If I use MailItem.Display() it gives the error in both cases (sending and not sending)

    Anybody has any idea what's going on?

    Thank you!

    Below is the code I'm using:

    Sub AutomateOutlook(sendTo As Variant, copyTo As Variant, subject As Variant, message As Variant, link As String)
    
    	Set appOutl = CreateObject("Outlook.Application")
    	Set myNameSpace = appOutl.GetNameSpace("MAPI")
    	Dim maiMail As Variant 
    	Set maiMail = appOutl.CreateItem(olMailItem)
    
    
    With maiMail
    
          'add recipients
          'add cc recipients		
          .Recipients.ResolveAll
          'Set body format to HTML
          'Set HTML body
    		
          'Display Mail Model to user
          .Display() 'Automation object error
    End With	
    	
        ' Close object references.
    	Set appOutl = Nothing
    	Set maiMail = Nothing
    	Set sendTo = Nothing
    End Sub
    


    Tuesday, March 5, 2013 10:44 AM

Answers

All replies

  • what error exactly?
    Tuesday, March 5, 2013 11:42 AM
  • Lotus Notes only give this: "Automation object error"

    Notes Help gives this as info for this error:

    Automation-Object error

    An error occurred when you tried to refer to an OLE Automation object.

    Check the syntax of the statement that caused the error, and check the documentation for the OLE Automationobject to which you tried to refer.

    I've read the Developer Reference for MailItem.Display but it was not much of help.

    Tuesday, March 5, 2013 11:51 AM
  • try to run it from script outside of lotus notes
    Tuesday, March 5, 2013 12:01 PM
  • Hello DamianD, thanks for your replies.

    I tried it on VBA for Excel, no error.

    The problem might be with LotusNotes and I've posted the same issue on their forums.

    But I can't really be sure, so if anyone has any idea, I'll be very glad to hear it.

    Thank you!

    Thursday, March 7, 2013 1:47 AM
  • is outlook running when you invoke your script inside lotus notes?
    Thursday, March 7, 2013 5:05 AM
  • yes, it's running.

    Thursday, March 7, 2013 5:13 AM
  • then you should be using GetObject, not CreateObject
    Thursday, March 7, 2013 7:37 AM