UtterAccess.com
We have detected that you are using an unsupported web browser. We recommend you to upgrade your web browser to get the most from UtterAccess forums.
Why should and how can I upgrade?
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Access 2010 to Outlook    
 
   
kjahn
post Jun 20 2010, 12:14 PM
Post #1

New Member
Posts: 5



Recently I upgraded from Office 2010 Beta to Office 2010 Professional.
Running on windows7.
This code works if Outlook is open, but doesn't work if Outlook is closed.
Oneed to get it to work if Outlook is closed too.
Sub SendMessage_Outlook(strTitle As String, strMsg As String)
On Error GoTo Err_SendMessage_Outlook
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Const SendAlways = "anyone@email.net"
'- Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
'-Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
.To = SendAlways
.Subject = strTitle
.Body = strMsg
.ReadReceiptRequested = False
.Send
End With

Set objOutlookMsg = Nothing
Set objOutlook = Nothing

Exit_SendMessage_Outlook:
Exit Sub
Err_SendMessage_Outlook:
MsgBox Err.Description
Resume Exit_SendMessage_Outlook
End Sub

The error I get is at the send command.
The error is Application - Defined or object - defined error.
HAs I stated earlier, it works if Outlook is open, and it worked either way in office 2010 beta.
Any help will be greatly appreciated.
Thank you.
Go to the top of the page
 
+
KimbleG
post Jun 20 2010, 01:59 PM
Post #2

UtterAccess Guru
Posts: 652
From: Auckland, New Zealand



Hi,
Are you by any chance using 64 bit Outlook ?
imbo
Go to the top of the page
 
+
kjahn
post Jun 20 2010, 03:02 PM
Post #3

New Member
Posts: 5



No everything is 32 bit.
Default installation across the board.
Go to the top of the page
 
+
KimbleG
post Jun 20 2010, 03:04 PM
Post #4

UtterAccess Guru
Posts: 652
From: Auckland, New Zealand



Hi,
Could I suggest you try 'Late Binding'.
imbo
Go to the top of the page
 
+
kjahn
post Jun 20 2010, 04:18 PM
Post #5

New Member
Posts: 5



Late binding didn't work either.
Otried 2 different ways for late binding.
blockquote>Sub SendMessage_Outlook(strTitle As String, strMsg As String)
On Error GoTo Err_SendMessage_Outlook
Const objMailItem As Long = 0

Dim objOutlook As Object
Dim objMail As Object
Set objOutlook = CreateObject("C:\Program Files\Microsoft Office\Office14\OUTLOOK.EXE")
Set objMail = objOutlook.CreateItem(olMailItem)
objMail.Subject = strTitle
objMail.Body = strMsg
objMail.To = "someone@email.net"
objMail.Send

Set objMail = Nothing
Set objOutlook = Nothing
objOutlook.Quit
Exit_SendMessage_Outlook:
Exit Sub
Err_SendMessage_Outlook:
MsgBox Err.Description
Resume Exit_SendMessage_Outlook
End Sub
I got the error on the createobject line:
ActiveX component can't create object
With this createobject line:
Set objOutlook = CreateObject("Outlook.Application")
I get the same Application-defined or object-defined error when it gets to the send command.
Go to the top of the page
 
+
KimbleG
post Jun 20 2010, 04:29 PM
Post #6

UtterAccess Guru
Posts: 652
From: Auckland, New Zealand



Hi,
From my reading of Outlook 2010 and the upgrading issues .....
site....
Outlook 2010
there is nothing to suggest that this code shouldn't work.
I've got no other suggestions, other than to suggest (if you haven't already done so) to follow the recommendations in the link provided (maybe a problem associated with your upgrade path - or a re-install might help.) iconfused.gif
Hopefully someone else might jump in to this train and suggest something else.
Sorry I can't be more helpful.
Kimbo acclaim.gif
Go to the top of the page
 
+
bravofoxtrotuk
post Oct 4 2011, 03:15 AM
Post #7

New Member
Posts: 2



I know this is an old posting, but I've just come across the same problem - code worked for years on Outlook 2003, 2007, but on installing Outlook 2010 this year it won't send properly unless Outlook is already open. I have late binding code code which is very similar to the OP's, in module fSendMail called with a 'True' at the end thus:
SendMail (MyAddressee), (MySubjectLine), , , (MyMessageText1 & MyMessageText2 & MyMessageText3 & MyMessageText4 & MyMessageText5 & MyMessageText6 & _
MyMessageText7 & MyMessageText8 & MyMessageText9 & MyMessageText10 & MyMessageText11 & MyMessageText12 & MyMessageText13 & MyMessageText14 & _
MyMessageText15 & MyMessageText16), , True
this causes the first email message to be opened for checking, with the user having to click the 'send' button in the email to complete the action.
(I've omitted most of the earlier code for now):
[snippet]
If boolShowMessage = True Then ' show user mail message
.Save
.Display
fSendMail = True
Else 'just send it
.Send
fSendMail = True
End If
That first email will go to the Outlook outbox correctly even when Outlook is not already open. My code then loops and attempts to send multiple emails using the same code but with 'False' set. All those later emails will fail at the .send following the 'else' in the snippet above, with an error code of 0. If I open Outlook in the background first, it sends them perfectly.
I've tried the same code on another machine with Outlook 2003/Access 2003 and it works fine (using 'yesno.exe' to make it easier).
On my development machine I can run Access 2003, 2007, and 2010, and with Outlook 2010 they all do the same - the subsequent emails fail - so it's definitely Outlook 2010. In my case it's not feasible to always set the flag 'true' as I can be sending over 100 emails at a time, and clicking that 'send' button each time is, well...
I've tried all kinds, but for now the workaround for my users has to be if they use Outlook 2010 to tell them to open it and leave it open in the background, unless anyone has found a better answer?
Go to the top of the page
 
+
mandrews
post Oct 4 2011, 07:55 AM
Post #8

UtterAccess Guru
Posts: 603



I would suggest uninstalling and reinstalling Office 2010. Usually the easiest way to resolve weird issues with automation.
My two cents,
Mark
Go to the top of the page
 
+
bravofoxtrotuk
post Oct 5 2011, 02:59 AM
Post #9

New Member
Posts: 2



Hi Mark,
lready done that (a few times!) but it stays the same. It's not that big a problem - more of a niggle.
Bob
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 31st October 2014 - 04:21 PM