Lotus Notus send email with VBA - problem with version 9

dandion1

New Member
Joined
Jun 4, 2016
Messages
4
I have a VBA procedure that send email with Lotus Notes. It works perfectly until an upgrade to Lotus Notes 9.0 was done. Now, whenever the macro is run there is a run-time errors.

Codes:

Code:
Sub SendEmailCandidat1()    Dim stFileName As String
    Dim stRecipients As String
    Dim noSession As Object
    Dim noDatabase As Object
    Dim noDocument As Object
    Dim noEmbedObject As Object
    Dim noAttachment As Object
    Dim stAttachment As String
    Dim stSubject As String
    Dim vaMsg As Variant
    Dim vaCopyTo As Variant
 
    stRecipients = Range("email.employee").Value
    stAttachment = ""
    stSubject = Range("Email.subject1").Value
    vaMsg = Range("Email.body1").Value
    vaCopyTo = ""
  
    'Instantiate the Lotus Notes COM's Objects.
    Set noSession = CreateObject("Notes.NotesSession")
    Set noDatabase = noSession.GETDATABASE("", "")
 
    'If Lotus Notes is not open then open the mail-part of it.
    If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
 
    'Create the e-mail and the attachment.
    Set noDocument = noDatabase.CreateDocument
    Set noAttachment = noDocument.CreateRichTextItem("stAttachment")
    Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
 
    'Add values to the created e-mail main properties.
    With noDocument
        .Form = "Memo"
        .SendTo = stRecipients
        .CopyTo = vaCopyTo
        .Subject = stSubject
        .Body = vaMsg
        .SaveMessageOnSend = True
        .PostedDate = Now()
        .Send 0, stRecipients
    End With
 
    'Release objects from memory.
    Set noEmbedObject = Nothing
    Set noAttachment = Nothing
    Set noDocument = Nothing
    Set noDatabase = Nothing
    Set noSession = Nothing

End Sub

 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
What is the exact error message and which line causes it? Click the Debug button on the error message window and the errant line is highlighted in yellow.
 
Upvote 0
Sorry my client Excel is in french, the error message:

Erreur d'exécution '-2147023170 (800706be)

Erreur Automation
Échec de l'appel de procédure distante

Possible translation in English
Execution error '-2147023170 (800706be)
Automation error
Remote procedure call failed.

The VBA line causing the error:
Set noEmbedObject = noAttachment.EmbedObject(EMBED_ATTACHMENT, "", stAttachment)
 
Upvote 0
The code sets stAttachment to "" and then tries to attach it. Try deleting or commenting out the Set noEmbedObject line.
 
Upvote 0

Forum statistics

Threads
1,216,225
Messages
6,129,597
Members
449,520
Latest member
TBFrieds

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top