Code for Outlookworked now it doesn't ?!?!

jayhawker

New member
Local time
Today, 08:16
Joined
May 25, 2015
Messages
6
Currently, I'm using MS Office Professional Plus 2010 and Windows 8.1. This code worked just fine then I started getting the 287 Error (Application Defined error). This is pretty frustrating any thoughts on how I can get it to work consistently????? Thank you in advance!!


PHP:
Function SendStuff_THISWORKED()


  Dim Email As String

  Dim objOutlook As Object
  Dim objEmail As Object
   
  

  Set objOutlook = CreateObject("Outlook.Application")
  Set objEmail = objOutlook.CreateItem(olMailItem)
   
  With objEmail
      .To = "xxxxxxx@xxxxxx.com"
      '.CC = strto
      '.BCC = strto
      .Subject = "Subject"
      .Body = "Body"
      .Send
  End With
   
  Set objOutlook = Nothing
  Set objEmail = Nothing

End Function
 
Hi, welcome to the forum.

Which line causes the error?
 
Sorry.

. Send
 
Hi
It looks similar to code I have. I have used .display instead of .send....
However, if you put some error handling in so that the objects are set to nothing after an error, this may help... (or may not - I'm guessing)
HTH
T
 
It might just be an Outlook setting that's preventing it from sending, so using .Display as TimW advised, should display the security alert (if it turns out to be the case).
 
It works now and all I did was:

1 Change .Send to .Display
2 Ran code (Outlook popped up with my email information)
3 Change .Display back to .Send
4 Ran code and email was sent no issues

WEIRDNESS!!!!!
 

Users who are viewing this thread

Back
Top Bottom