WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Problem automating Outlook 2007 in VB6

 
   Home -> Office -> Programming VBA RSS
Next:  Clean Free Busy Programmatically ?  
Author Message
Norm

External


Since: Sep 23, 2008
Posts: 2



(Msg. 1) Posted: Tue Sep 23, 2008 5:56 pm
Post subject: Problem automating Outlook 2007 in VB6
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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. Smile

normfowler_don't use_.DeleteThis@hotmail.com
Back to top
Login to vote
Ken Slovak - [MVP - Outlo

External


Since: Oct 17, 2003
Posts: 2898



(Msg. 2) Posted: Wed Sep 24, 2008 9:19 am
Post subject: Re: Problem automating Outlook 2007 in VB6 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <NormF4.TakeThisOut@newsgroups.nospam> wrote in message
news:OpK%23dBeHJHA.1940@TK2MSFTNGP03.phx.gbl...
> 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. Smile
>
> normfowler_don't use_.TakeThisOut@hotmail.com
>
Back to top
Login to vote
Norm

External


Since: Sep 23, 2008
Posts: 2



(Msg. 3) Posted: Wed Sep 24, 2008 2:15 pm
Post subject: Re: Problem automating Outlook 2007 in VB6 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
Back to top
Login to vote
Ken Slovak - [MVP - Outlo

External


Since: Oct 17, 2003
Posts: 2898



(Msg. 4) Posted: Wed Sep 24, 2008 6:47 pm
Post subject: Re: Problem automating Outlook 2007 in VB6 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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" <NormF4 RemoveThis @newsgroups.nospam> wrote in message
news:epiZhqoHJHA.1364@TK2MSFTNGP04.phx.gbl...
>
> 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
>
Back to top
Login to vote
Display posts from previous:   
       Home -> Office -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
  Office
 Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET