sotirop / mergelook

Mail Merge with Attachments using Outlook
26 stars 13 forks source link

Run-time error '287': application-defined or object-defined error in Outlook 365 with MS Excel 365. #3

Open raj-gthub opened 3 years ago

raj-gthub commented 3 years ago

Hi,

I am getting following error when I am using Mergelook in Outlook 365 with Excel 365 in Windows 10 OS.

image

image

With my limited VBA knowledge tried all to fix this error but tough luck so far. Any Help would be really appreciated.

Cheers

sotirop commented 3 years ago

Could you please send me a simplified version of the excel file that produces the error? Remove all the unnecessary info from the file, before you send it.

raj-gthub commented 3 years ago

Thank you for your quick reply.

I am using your default files. I haven't made any changes.

mergelook-master.zip

image

Can you please try sending email in Windows 10 and see if it works? It used to work in Windows 8.1 64-bit but ever since I updated to Windows 10 64-bit it is not working.

I came across similar issue here - https://stackoverflow.com/questions/33001048/cant-set-up-mail-with-vba-when-changed-to-windows-10

sotirop commented 3 years ago

I just used my example file from mergelook-master, I changed the email addresses to real ones and tried it in a latest Windows 10 box. It worked!

raj-gthub commented 3 years ago

Thanks Aris for your help.

I believe that I am getting this error as our IT admin has changed the Macro security settings with Windows 10 OS update.

I tried to run macro with self signed certificate but no luck so far :(

I am not sure how I can run macro now. I guess now I again have to get back to sending hundreds of emails with attachment manually one-by-one every month. Life was so easy with mergelook.

image

PS: I changed email address from real to dummy in screenshot

sotirop commented 3 years ago

I just created my own certificate and signed the code. See if it works now.

raj-gthub commented 3 years ago

Hi Aris,

Thanks for your help.

I am still getting same error.

It seems certificate wasn't the issue or the Macro settings of Outlook. As I can send email with attachment using below code (copied from https://wellsr.com/vba/2018/excel/excel-vba-send-email-with-attachment/). The issue with this code is it is very basic VBA which don't allow dynamic functions like mergelook. Mergelook is perfect for sending multiple emails with multiple attachment.

Here, I was trying different macros to see if security setting is really an issue that I am facing. So Far I have failed to understand what is preventing mergelook from sending an email.

Sub send_email_complete()
Dim outlookApp As Outlook.Application
Dim myMail As Outlook.MailItem
Dim source_file, to_emails, cc_emails As String
Dim i, j As Integer

Set outlookApp = New Outlook.Application
Set myMail = outlookApp.CreateItem(olMailItem)

For i = 2 To 4
    to_emails = to_emails & Cells(i, 1) & ";"
    cc_emails = cc_emails & Cells(i, 2) & ";"
Next i

For j = 2 To 5
    source_file = "C:\Work Files\" & Cells(j, 3)
    myMail.Attachments.Add source_file
Next

ThisWorkbook.Save
source_file = ThisWorkbook.FullName
myMail.Attachments.Add source_file

myMail.CC = cc_emails
myMail.To = to_emails
myMail.Subject = "Files for Everyone"
myMail.Body = "Hi Everyone," & vbNewLine & "Please read these before the meeting." & vbNewLine & "Thanks"

myMail.Display

End Sub
raj-gthub commented 3 years ago

It looks like this guy also have same issue

https://www.mrexcel.com/board/threads/excel-vba-mail-create-and-send-error.1125720/

raj-gthub commented 2 years ago

I tried using your new version file but I am still having same issue.

It looks like other ppl are also having similar issue with your file as mine.

https://stackoverflow.com/questions/72209404/sending-email-working-in-older-version-but-not-working-in-latest-version-of-exce

Our IT team also tried fixing the issue with no luck.

vera132320 commented 2 years ago

Hi Collegaues! We have used the mergelook makro for many years. It helps a lot to send individualized e-mails for more thousend employees. Since my company changed from Office 2016 to M365 Office (latest version) we have the same issue than raj-gthub. - It doesnt work any more, with the same error '287' message :( The only soultion is that we "downgrade" back to Office 2016, and then it works again. But it is a sollution only for short time. A few month, and we will not be able to use Office 2016. What change can m365 cause, what prevents it from running? Greeting

sotirop commented 2 years ago

Hi! I don't have access to Excel Office 365 myself and cannot test the code.