UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Problem Sending Workbook Via Gmail Error 424 Object Required, Office 2013    
 
   
bakersburg9
post Aug 7 2019, 04:48 PM
Post#1



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


Not an Excel question per se, but I am trying to send e-mail via GMAIL - I have always used outlook in the past - getting error message - I got this from a tutorial where they were doing something with the object browser, but I didn't follow - could that be the problem ? How do you "select" items ? Double click, or hold down control when you select multiple items ?

CODE
Private Sub SendEmailViaGMAILversion2()
  
  Dim Mail As CDO.Message
  
  Set myMail = New CDO.Message
  
'Line 3 - blew up here - Error '424' Object required
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTuseSSL") = True
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTauthenticate") = 1
  
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTserver") = "smtp.gmail.com"
  
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTserverPort") = 25
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusing") = 2
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusername") = "steve.rollins@ATI.restoration.com"
  myMailConfiguration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendpassword") = "MyPassword"
  myMailConfiguration.Fields.Update
  
  With myMail
  .Subject = "Email subject here"
  .from = "steve.rollins@ATIrestoration.com"
  .To = "steve.rollins@ATIrestoration.com"
  .CC = "steve.rollins@ATIrestoration.com"
  .BCC = ""
  .TextBody = "Good Morning! Here is your report!"
  .AddAttachment "C:\Users\Steve.rollins\Documents\SteveR\Cost Zero Billing 2017-01-01 to 2018-12-31_Combined.xlsm"
  
  End With
  
   On Error Resume Next
  
  myMail.Send
  
  
  
  End Sub
Any help would be greatly appreciated
Go to the top of the page
 
theDBguy
post Aug 7 2019, 04:52 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,290
Joined: 19-June 07
From: SunnySandyEggo


Hi. I believe for the CDO approach to work with GMail, you'll have to change your GMail settings to allow access to "less-secured" applications.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
bakersburg9
post Aug 7 2019, 05:14 PM
Post#3



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


DbGuy,
I looked that up, and it says to: "Sign in to your Google Admin console. Sign in using an administrator accoount - your Google Admin console. I'm lost at Jump - where/how do I do THAT?
Go to the top of the page
 
theDBguy
post Aug 7 2019, 05:18 PM
Post#4


Access Wiki and Forums Moderator
Posts: 76,290
Joined: 19-June 07
From: SunnySandyEggo


Hi. Not in front of a computer now. I’ll check when I get home.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ipisors12
post Aug 7 2019, 06:04 PM
Post#5



Posts: 9
Joined: 14-March 19



try changing Dim Mail As CDO.Message to Dim myMail As CDO.Message

You're trying to Set a non-existent variable.

Good luck with CDO, I sincerely hope you are lucky with it - I've tried it for years, and eventually wrote it off as "so finicky" I refused to beat my head against a wall any more. So many firewall type considerations, it worked 1/3 of the time and didn't 2/3 of the time, and the 2/3 was fraught with issues requiring extensive operating system and networking type knowledge. When it works it's beautiful, and yes as dbGuy says, you have to find the well-buried Gmail setting for "allow access for less-secure apps", but that's the easiest hurdle to solve.
This post has been edited by ipisors12: Aug 7 2019, 06:06 PM
Go to the top of the page
 
bakersburg9
post Aug 7 2019, 06:09 PM
Post#6



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


Thank YOU!
Go to the top of the page
 
theDBguy
post Aug 7 2019, 09:34 PM
Post#7


Access Wiki and Forums Moderator
Posts: 76,290
Joined: 19-June 07
From: SunnySandyEggo


Hi Steve. Check out this link. Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Debaser
post Aug 8 2019, 07:04 AM
Post#8



Posts: 145
Joined: 11-October 18



You also appear to be missing dots in myMail.Configuration (rather than myMailconfiguration)
Go to the top of the page
 
bakersburg9
post Aug 8 2019, 09:28 AM
Post#9



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


Debaser,
I made that change you suggested, and it didn't err, but the e-mail didn't get sent - maybe a firewall issue ?

Steve
Go to the top of the page
 
cheekybuddha
post Aug 8 2019, 10:03 AM
Post#10


UtterAccess VIP
Posts: 11,469
Joined: 6-December 03
From: Telegraph Hill


Highly unlikely that it will work on port 25.

IIRC, you will need to use 993 or 465

--------------------


Regards,

David Marten
Go to the top of the page
 
Debaser
post Aug 8 2019, 10:04 AM
Post#11



Posts: 145
Joined: 11-October 18



Remove the OERN line before the line that sends the email. That way at least you'll know if it goes wrong!
Go to the top of the page
 
bakersburg9
post Aug 8 2019, 10:40 AM
Post#12



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


Debaser,
QUOTE
OERN
? What does the Oppose Europe Research Network have to do with this ?

j/k - great idea ? I commented out On Error Resume Next, and it ran - kind of - at first - got the message that it was sent from a msgbox line, then this nastygram:

CODE
Run-time error '-2147720982 (8004020a)';  The SMTP server name is required, and was not found in the configuration source

... that was with server port 993 - I also ran it with port 25 (not recommended by Cheeky) and 465

Here's my code:
CODE
  
  Dim Mail As CDO.Message
    Set myMail = New CDO.Message
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTuseSSL") = True
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTauthenticate") = 1
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTserver") = "smtp.gmail.com"

  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTserverPort") = 465
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusing") = 2
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusername") = "steve.rollins@ATI.restoration.com"
  myMail.configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendpassword") = "MyPassword"
  myMail.Configuration.Fields.Update
    
  With myMail
  .Subject = "Email subject here"
  .from = "steve.rollins@ATIrestoration.com"
  .To = "steve.rollins@ATIrestoration.com"
  .CC = "steve.rollins@ATIrestoration.com"
  .BCC = ""
  .TextBody = "Good Morning! Here is your report!"
  .AddAttachment "C:\Users\Steve.rollins\Documents\SteveR\Cost Zero Billing 2017-01-01 to 2018-12-31_Combined.xlsm"
  
  
MsgBox "your e-mail has been sent!", vbInformation, "Sent"


  End With
  
'********************************* Test 8/8 - want to know if something goes wrong - temporarily commented out
'  On Error Resume Next
  
  myMail.Send

This post has been edited by bakersburg9: Aug 8 2019, 10:42 AM
Go to the top of the page
 
Debaser
post Aug 8 2019, 10:44 AM
Post#13



Posts: 145
Joined: 11-October 18



It looks like you misspelled SMTP as SMPT in a few of the configuration options.
Go to the top of the page
 
cheekybuddha
post Aug 8 2019, 10:47 AM
Post#14


UtterAccess VIP
Posts: 11,469
Joined: 6-December 03
From: Telegraph Hill


QUOTE
CODE
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTuseSSL") = True
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTauthenticate") = 1
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMPTserver") = "smtp.gmail.com"


You need to copy/paste the schema strings from a better source! dazed.gif

(They contain 'SMPT' rather than 'SMTP' - ain't gonna work!)

--------------------


Regards,

David Marten
Go to the top of the page
 
bakersburg9
post Aug 8 2019, 11:04 AM
Post#15



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


Thanks for catching that!

I still get the same error message

CODE
  Dim Mail As CDO.Message
  
  Set myMail = New CDO.Message
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPuseSSL") = True
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPauthenticate") = 1
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPserver") = "smtp.gmail.com"
  
'Commented out - port 25 - try 993 or 465
  'myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPserverPort") = 25
  
'Commented out - port 465 - try 993
'  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPserverPort") = 465
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPserverPort") = 993
  
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusing") = 2
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusername") = "steve.rollins@ATI.restoration.com"
  myMail.configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendpassword") = "MyPassword"
  myMail.Configuration.Fields.Update
  
  
  With myMail
  .Subject = "Email subject here"
  .from = "steve.rollins@ATIrestoration.com"
  .To = "steve.rollins@ATIrestoration.com"
  .CC = "steve.rollins@ATIrestoration.com"
  .BCC = ""
  .TextBody = "Good Morning! Here is your report!"
  .AddAttachment "C:\Users\Steve.rollins\Documents\SteveR\Cost Zero Billing 2017-01-01 to 2018-12-31_Combined.xlsm"
  
MsgBox "your e-mail has been sent!", vbInformation, "Sent"


  End With
  
'********************************* Test 8/8 - want to know if something goes wrong - temporarily commented out
'  On Error Resume Next
  
  myMail.Send

This post has been edited by bakersburg9: Aug 8 2019, 11:05 AM
Go to the top of the page
 
theDBguy
post Aug 8 2019, 11:12 AM
Post#16


Access Wiki and Forums Moderator
Posts: 76,290
Joined: 19-June 07
From: SunnySandyEggo


Hi. Not sure if it will help but take a look at this previous discussion as well just in case you might get something out of it.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
PhilS
post Aug 8 2019, 11:36 AM
Post#17



Posts: 614
Joined: 26-May 15
From: The middle of Germany


My bet:
The URLs to identify the configuration settings are case sensitive and should be all lower case.

--------------------
Go to the top of the page
 
bakersburg9
post Aug 8 2019, 11:58 AM
Post#18



Posts: 5,555
Joined: 2-November 04
From: Downey, CA


Phil,
You mean that
CODE
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/SMTPuseSSL") = True

should be
CODE
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/smtpusessl") = True
?

Phil,
I tried that, and got a DIFFERENT error message:
CODE
Run-time error '-2147220973 (80040213)': The transport failed to connect to the server.
interesting...

Here's what I'm using:
CODE
  Dim Mail As CDO.Message
  
  Set myMail = New CDO.Message


  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/smtpusessl") = True
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/smtpauthenticate") = 1
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/smtpserver") = "smtp.gmail.com"
  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/smtpserverPort") = 465
  

  
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusing") = 2
  myMail.Configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendusername") = "steve.rollins@ATI.restoration.com"
  myMail.configuration.Fields.Item("http://schemas.microsoft.com/CDO/configuration/sendpassword") = "MyPassword"
  myMail.Configuration.Fields.Update
  
  
  With myMail
  .Subject = "Email subject here"
  .from = "steve.rollins@ATIrestoration.com"
  .To = "steve.rollins@ATIrestoration.com"
  .CC = "steve.rollins@ATIrestoration.com"
  .BCC = ""
  .TextBody = "Good Morning! Here is your report!"
  .AddAttachment "C:\Users\Steve.rollins\Documents\SteveR\Cost Zero Billing 2017-01-01 to 2018-12-31_Combined.xlsm"
  
  
MsgBox "your e-mail has been sent!", vbInformation, "Sent"


  End With
  
'********************************* Test 8/8 - want to know if something goes wrong - temporarily commented out
'  On Error Resume Next
  
  myMail.Send

This post has been edited by bakersburg9: Aug 8 2019, 12:06 PM
Go to the top of the page
 
PhilS
post Aug 9 2019, 01:53 AM
Post#19



Posts: 614
Joined: 26-May 15
From: The middle of Germany


Yes, that's what I meant. - Great, we're getting somewhere...
QUOTE
tried that, and got a DIFFERENT error message:
CODE
Run-time error '-2147220973 (80040213)': The transport failed to connect to the server.
interesting...

I think, this indicates some problem external to the source code. Like a firewall preventing the connection...

You can counter-check by trying the sample code from my text on CDO with VBA. The sample proc SendSimpleCDOMailWithAuthenticationAndEncryption works with Googlemail (with "Less secure apps"=ON); I verified it minutes ago. - If that fails with the same error message, the cause is something on your network.

--------------------
Go to the top of the page
 
Debaser
post Aug 9 2019, 07:39 AM
Post#20



Posts: 145
Joined: 11-October 18



If it is case sensitive, then CDO needs to become CDO in the URL. (I'd also move that root path to a variable/constant rather than repeating it)
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search


RSSSearch   Top   Lo-Fi    16th September 2019 - 01:27 AM