A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem automating Outlook 2007 in VB6



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 24th 08, 01:56 AM posted to microsoft.public.outlook.program_vba
Norm[_2_]
external usenet poster
 
Posts: 4
Default Problem automating Outlook 2007 in VB6

Hi,

I thought I would try this question here since VBA is very similar to VB6.

I have the following code, which worked find in previous versions of Office
and Outlook so I am assuming Office 2007 is having a problem with resolving
email address. On these two lines I am getting just an object or application
defined error, but no explanation of what the error is.

oMail.Recipients.ADD MyReport

bCheck = oMail.Recipients.ResolveAll

objEmail and oMail are dim'ed as objects, while bCheck is boolean.

Code:

Set objEmail = CreateObject("Outlook.Application")

Do

Set oMail = objEmail.CreateItem(olMailItem)

bCheck = False

sPath = CStr(i)

MyReport = sGetINI(sIniPath, "Path", sPath, Default)

If MyReport = "" Or MyReport = "0" Then Exit Do

oMail.Recipients.ADD MyReport 'First error generated here

bCheck = oMail.Recipients.ResolveAll 'This line will also generate
an error

If Not bCheck Then

AllReports2 = MyPath2 & MyReport

MyPath2 = AllReports2 & ";"

GoTo Skip

End If

AllReports = MyPath & MyReport

MyPath = AllReports & ";"

Skip:

Set oMail = Nothing

i = (i + 1)

Loop




--
Norm

Don't blame me, my programming is
self-taught and my teacher was not
very experienced. :-)

normfowler_don't


  #2  
Old September 24th 08, 02:19 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Problem automating Outlook 2007 in VB6

There shouldn't be any problem in adding recipients using the
Recipients.Add() function, although best practice would be to set a
Recipient object to the return value of that function. I've done it many
times in VB6 code in Outlook 2007 with no errors.

Are you positive that MyReport is actually a valid email address or a name
that will resolve to a valid contact or global address list entry?

Does it make a difference if you early bind those Object declarations as the
actual types (oMail as MailItem and objEmail as Outlook.Application)?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Norm" wrote in message
...
Hi,

I thought I would try this question here since VBA is very similar to VB6.

I have the following code, which worked find in previous versions of
Office
and Outlook so I am assuming Office 2007 is having a problem with
resolving
email address. On these two lines I am getting just an object or
application
defined error, but no explanation of what the error is.

oMail.Recipients.ADD MyReport

bCheck = oMail.Recipients.ResolveAll

objEmail and oMail are dim'ed as objects, while bCheck is boolean.

Code:

Set objEmail = CreateObject("Outlook.Application")

Do

Set oMail = objEmail.CreateItem(olMailItem)

bCheck = False

sPath = CStr(i)

MyReport = sGetINI(sIniPath, "Path", sPath, Default)

If MyReport = "" Or MyReport = "0" Then Exit Do

oMail.Recipients.ADD MyReport 'First error generated here

bCheck = oMail.Recipients.ResolveAll 'This line will also generate
an error

If Not bCheck Then

AllReports2 = MyPath2 & MyReport

MyPath2 = AllReports2 & ";"

GoTo Skip

End If

AllReports = MyPath & MyReport

MyPath = AllReports & ";"

Skip:

Set oMail = Nothing

i = (i + 1)

Loop




--
Norm

Don't blame me, my programming is
self-taught and my teacher was not
very experienced. :-)

normfowler_don't


  #3  
Old September 24th 08, 10:15 PM posted to microsoft.public.outlook.program_vba
Norm[_2_]
external usenet poster
 
Posts: 4
Default Problem automating Outlook 2007 in VB6


Ken,

Thanks for the information, I did get it to work, by the early binding and
also by using objOut.Session.Logon when Outlook is not already open.

Norm


  #4  
Old September 24th 08, 11:47 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Problem automating Outlook 2007 in VB6

Standalone code then, not Outlook VBA or an addin. You could now go back to
using late bound Objects if you wanted with .Logon being used, although
early bound objects provide intellisense and are faster.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Norm" wrote in message
...

Ken,

Thanks for the information, I did get it to work, by the early binding and
also by using objOut.Session.Logon when Outlook is not already open.

Norm


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem automating outlook John Outlook - General Queries 1 February 11th 08 07:00 PM
Automating Outlook Andrew Kennard Outlook and VBA 1 December 20th 06 03:27 PM
Automating Outlook Reminders Darren Hermes Outlook and VBA 1 August 23rd 06 01:39 PM
Problem automating outlook John Outlook - General Queries 6 March 27th 06 02:51 PM
Problem automating outlook John Outlook and VBA 6 March 27th 06 02:51 PM


All times are GMT +1. The time now is 10:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.