Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Computer Security > Macros and Outlook?

Reply
Thread Tools

Macros and Outlook?

 
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      11-06-2003
Did you restart Outlook after changing the macro security setting to Low? If so, does any other VBA code run? Write a "hello world" MsgBox routine if you need something to test. Did you try putting a breakpoint in the Application_ ItemSend() event handler?

You can make a basic check of whether there's a problem with Redemption by looking at Tools | Options | Other | Advanced Options | Addin Manager. It should appear there.

> Also, how whould I change the contact address book to work with? Would I
> change the line
>
> Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
>
> To something like Set colContacts = “NewAddressBook”


Contacts folders and address books are *not* the same thing, so I'm not sure what you're getting at.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message news:e2yqb.92080$mZ5.603450@attbi_s54...
> I D/L redemption, and installed it. I then tried to register it in VB (I
> have 2 entries for SafeOutlookLibrary and both point to redemption.dll) When
> I restarted OL 2002, I got an error that it could not find extend.dat (or
> extra.dat if I look in event log. I THOUGHT it said extend.dat ) (I cleared
> the message, as I thought I would be able to get it again by restarting O/L-
> I have not been able to get the error again….)
>
> I have pressed ALT-11, starting the VBA editor, and then browsed to
> ThisOutlookSession and pasted the whole code section there. I have since
> moved all but the first section into a diff module.
>
> I then tried to run it by creating a new email to a address that was not in
> the contacts folder. I did not get any response. I then put a msgbox in the
> code, expecting it to pop the message box, it did not. I am NOT familiar
> with O/L for VBA, but I have done some in EXCEL, so it SHOULD be similair…
>
> I have not tried any other VBA code. I have not had any need for it. what
> would be a good one to just test something?
>
> I have signed the code with selfcert and I have also put security to LOW.
>
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> Did you check your macro security settings -- Tools | Macro | Security? Does
> other VBA code run?
>
> If you're using Excel to send out the mail, then you should be able to adapt
> the code I provided to add the same functionality (checking addresses and
> creating contacts) to your Excel routines.
>
> "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> news:M3vqb.128842$HS4.1023070@attbi_s01...
> >
> > Thanks for the link!
> > I tried the code, but, it did not work....
> > I even put a msgbox inthe code so I could see if it was getting to the

> code.
> > It is not. I did put it in the correct folder, as per the instructions.
> >
> > Back to the origianal issue...
> >
> > Now, is there a way, I can do something similar from EXCEL? I use the VBA

> to
> > send out all of the email I am actually looking for. All of the email I

> send
> > out of OL, I don't need to put into the fold, as I do not need to follow
> > their email perse. Or does it need to be called from Outlook?
> >
> > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > Great, Bruce. You might find this code useful, too:
> > http://www.slipstick.com/contacts/addauto.htm


 
Reply With Quote
 
 
 
 
BruceJ
Guest
Posts: n/a
 
      11-06-2003
Did you restart Outlook after changing the macro security setting to Low?
>I thought I did... I did restart again and my Hello World worked.

Now I am getting
run-time error '424':
Object required
and debug puts me at
For Each objSRecip In objSMail.Recipients
objSMail.Recipients = nothing when I place my mouse over it.

Thanks
Bruce


"Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Did you restart Outlook after changing the macro security setting to Low? If
so, does any other VBA code run? Write a "hello world" MsgBox routine if you
need something to test. Did you try putting a breakpoint in the Application_
ItemSend() event handler?

You can make a basic check of whether there's a problem with Redemption by
looking at Tools | Options | Other | Advanced Options | Addin Manager. It
should appear there.

> Also, how whould I change the contact address book to work with? Would I
> change the line
>
> Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
>
> To something like Set colContacts = “NewAddressBook”


Contacts folders and address books are *not* the same thing, so I'm not sure
what you're getting at.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
news:e2yqb.92080$mZ5.603450@attbi_s54...
> I D/L redemption, and installed it. I then tried to register it in VB (I
> have 2 entries for SafeOutlookLibrary and both point to redemption.dll)

When
> I restarted OL 2002, I got an error that it could not find extend.dat (or
> extra.dat if I look in event log. I THOUGHT it said extend.dat ) (I

cleared
> the message, as I thought I would be able to get it again by restarting

O/L-
> I have not been able to get the error again….)
>
> I have pressed ALT-11, starting the VBA editor, and then browsed to
> ThisOutlookSession and pasted the whole code section there. I have since
> moved all but the first section into a diff module.
>
> I then tried to run it by creating a new email to a address that was not

in
> the contacts folder. I did not get any response. I then put a msgbox in

the
> code, expecting it to pop the message box, it did not. I am NOT familiar
> with O/L for VBA, but I have done some in EXCEL, so it SHOULD be similair…
>
> I have not tried any other VBA code. I have not had any need for it. what
> would be a good one to just test something?
>
> I have signed the code with selfcert and I have also put security to LOW.
>
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> Did you check your macro security settings -- Tools | Macro | Security?

Does
> other VBA code run?
>
> If you're using Excel to send out the mail, then you should be able to

adapt
> the code I provided to add the same functionality (checking addresses and
> creating contacts) to your Excel routines.
>
> "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> news:M3vqb.128842$HS4.1023070@attbi_s01...
> >
> > Thanks for the link!
> > I tried the code, but, it did not work....
> > I even put a msgbox inthe code so I could see if it was getting to the

> code.
> > It is not. I did put it in the correct folder, as per the instructions.
> >
> > Back to the origianal issue...
> >
> > Now, is there a way, I can do something similar from EXCEL? I use the

VBA
> to
> > send out all of the email I am actually looking for. All of the email I

> send
> > out of OL, I don't need to put into the fold, as I do not need to follow
> > their email perse. Or does it need to be called from Outlook?
> >
> > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > Great, Bruce. You might find this code useful, too:
> > http://www.slipstick.com/contacts/addauto.htm



 
Reply With Quote
 
 
 
 
BruceJ
Guest
Posts: n/a
 
      11-06-2003
Sorry to be a pest <grin>

If I wanted it to add the contact info into a diff folder, would I change
the
Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
to
Set colContacts = "MyContactFolderNameHere"
If not, how would I cahnge the folder?
thanks

Bruce

"Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Did you restart Outlook after changing the macro security setting to Low? If
so, does any other VBA code run? Write a "hello world" MsgBox routine if you
need something to test. Did you try putting a breakpoint in the Application_
ItemSend() event handler?

You can make a basic check of whether there's a problem with Redemption by
looking at Tools | Options | Other | Advanced Options | Addin Manager. It
should appear there.

> Also, how whould I change the contact address book to work with? Would I
> change the line
>
> Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
>
> To something like Set colContacts = “NewAddressBook”


Contacts folders and address books are *not* the same thing, so I'm not sure
what you're getting at.
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
news:e2yqb.92080$mZ5.603450@attbi_s54...
> I D/L redemption, and installed it. I then tried to register it in VB (I
> have 2 entries for SafeOutlookLibrary and both point to redemption.dll)

When
> I restarted OL 2002, I got an error that it could not find extend.dat (or
> extra.dat if I look in event log. I THOUGHT it said extend.dat ) (I

cleared
> the message, as I thought I would be able to get it again by restarting

O/L-
> I have not been able to get the error again….)
>
> I have pressed ALT-11, starting the VBA editor, and then browsed to
> ThisOutlookSession and pasted the whole code section there. I have since
> moved all but the first section into a diff module.
>
> I then tried to run it by creating a new email to a address that was not

in
> the contacts folder. I did not get any response. I then put a msgbox in

the
> code, expecting it to pop the message box, it did not. I am NOT familiar
> with O/L for VBA, but I have done some in EXCEL, so it SHOULD be similair…
>
> I have not tried any other VBA code. I have not had any need for it. what
> would be a good one to just test something?
>
> I have signed the code with selfcert and I have also put security to LOW.
>
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> Did you check your macro security settings -- Tools | Macro | Security?

Does
> other VBA code run?
>
> If you're using Excel to send out the mail, then you should be able to

adapt
> the code I provided to add the same functionality (checking addresses and
> creating contacts) to your Excel routines.
>
> "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> news:M3vqb.128842$HS4.1023070@attbi_s01...
> >
> > Thanks for the link!
> > I tried the code, but, it did not work....
> > I even put a msgbox inthe code so I could see if it was getting to the

> code.
> > It is not. I did put it in the correct folder, as per the instructions.
> >
> > Back to the origianal issue...
> >
> > Now, is there a way, I can do something similar from EXCEL? I use the

VBA
> to
> > send out all of the email I am actually looking for. All of the email I

> send
> > out of OL, I don't need to put into the fold, as I do not need to follow
> > their email perse. Or does it need to be called from Outlook?
> >
> > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > Great, Bruce. You might find this code useful, too:
> > http://www.slipstick.com/contacts/addauto.htm



 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      11-06-2003
What statement instantiates objSMail?

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message news:Hfzqb.94247$275.262182@attbi_s53...
> Did you restart Outlook after changing the macro security setting to Low?
> >I thought I did... I did restart again and my Hello World worked.

> Now I am getting
> run-time error '424':
> Object required
> and debug puts me at
> For Each objSRecip In objSMail.Recipients
> objSMail.Recipients = nothing when I place my mouse over it.
>
> Thanks
> Bruce
>
>
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> Did you restart Outlook after changing the macro security setting to Low? If
> so, does any other VBA code run? Write a "hello world" MsgBox routine if you
> need something to test. Did you try putting a breakpoint in the Application_
> ItemSend() event handler?
>
> You can make a basic check of whether there's a problem with Redemption by
> looking at Tools | Options | Other | Advanced Options | Addin Manager. It
> should appear there.
>
> > Also, how whould I change the contact address book to work with? Would I
> > change the line
> >
> > Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> >
> > To something like Set colContacts = “NewAddressBook”

>
> Contacts folders and address books are *not* the same thing, so I'm not sure
> what you're getting at.
> --
> Sue Mosher, Outlook MVP
> Outlook and Exchange solutions at http://www.slipstick.com
> Author of
> Microsoft Outlook Programming: Jumpstart
> for Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> news:e2yqb.92080$mZ5.603450@attbi_s54...
> > I D/L redemption, and installed it. I then tried to register it in VB (I
> > have 2 entries for SafeOutlookLibrary and both point to redemption.dll)

> When
> > I restarted OL 2002, I got an error that it could not find extend.dat (or
> > extra.dat if I look in event log. I THOUGHT it said extend.dat ) (I

> cleared
> > the message, as I thought I would be able to get it again by restarting

> O/L-
> > I have not been able to get the error again….)
> >
> > I have pressed ALT-11, starting the VBA editor, and then browsed to
> > ThisOutlookSession and pasted the whole code section there. I have since
> > moved all but the first section into a diff module.
> >
> > I then tried to run it by creating a new email to a address that was not

> in
> > the contacts folder. I did not get any response. I then put a msgbox in

> the
> > code, expecting it to pop the message box, it did not. I am NOT familiar
> > with O/L for VBA, but I have done some in EXCEL, so it SHOULD be similair…
> >
> > I have not tried any other VBA code. I have not had any need for it. what
> > would be a good one to just test something?
> >
> > I have signed the code with selfcert and I have also put security to LOW.
> >
> > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > Did you check your macro security settings -- Tools | Macro | Security?

> Does
> > other VBA code run?
> >
> > If you're using Excel to send out the mail, then you should be able to

> adapt
> > the code I provided to add the same functionality (checking addresses and
> > creating contacts) to your Excel routines.
> >
> > "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> > news:M3vqb.128842$HS4.1023070@attbi_s01...
> > >
> > > Thanks for the link!
> > > I tried the code, but, it did not work....
> > > I even put a msgbox inthe code so I could see if it was getting to the

> > code.
> > > It is not. I did put it in the correct folder, as per the instructions.
> > >
> > > Back to the origianal issue...
> > >
> > > Now, is there a way, I can do something similar from EXCEL? I use the

> VBA
> > to
> > > send out all of the email I am actually looking for. All of the email I

> > send
> > > out of OL, I don't need to put into the fold, as I do not need to follow
> > > their email perse. Or does it need to be called from Outlook?
> > >
> > > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > Great, Bruce. You might find this code useful, too:
> > > http://www.slipstick.com/contacts/addauto.htm

>
>

 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      11-06-2003
To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.slipstick.com/dev/code/getfolder.htm

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message news:Oqzqb.95807$9E1.459957@attbi_s52...
> Sorry to be a pest <grin>
>
> If I wanted it to add the contact info into a diff folder, would I change
> the
> Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> to
> Set colContacts = "MyContactFolderNameHere"
> If not, how would I cahnge the folder?
> thanks
>


 
Reply With Quote
 
BruceJ
Guest
Posts: n/a
 
      11-06-2003
Here is the code I have (as you an see, just cut and paste now (I took out
my msgbox)
Redemtion.dll is present, Outlook DOES have it in the add-in manager.

Thanks
Bruce

' sample application by Sue Mosher
' send questions/comments to http://www.velocityreviews.com/forums/(E-Mail Removed)

' The Application_ItemSend procedure must go in the
' built-in ThisOutlookSession session module in Outlook VBA
Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Item.Categories = ""
If Item.Class = olMail Then
Call AddRecipToContacts(Item)
End If
End Sub

' This procedure can go in any module
Sub AddRecipToContacts(objMail As MailItem)
Dim strFind As String
Dim strAddress As String
Dim objSMail As Redemption.SafeMailItem
Dim objSRecip As Redemption.SafeRecipient
Dim objNS As NameSpace
Dim colContacts As Items
Dim objContact As ContactItem
Dim i As Integer

' process message recipients
Set objSMail = CreateObject("Redemption.SafeMailItem")
objMail.Save
objSMail.Item = objMail
Set objNS = Application.GetNamespace("MAPI")
Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
For Each objSRecip In objSMail.Recipients
' check to see if the recip is already in Contacts
strAddress = objSRecip.Address
For i = 1 To 3
strFind = "[Email" & i & "Address] = " & _
AddQuote(strAddress)
Set objContact = colContacts.Find(strFind)
If Not objContact Is Nothing Then
Exit For
End If
Next

' if not, add it
If objContact Is Nothing Then
Set objContact = Application.CreateItem(olContactItem)
With objContact
.FullName = objSRecip.Name
.Email1Address = strAddress
.Save
End With
End If
Set objContact = Nothing
Next

Set objSMail = Nothing
Set objSRecip = Nothing
Set objNS = Nothing
Set colContacts = Nothing
End Sub

' helper function - put in any module
Function AddQuote(MyText) As String
AddQuote = Chr(34) & MyText & Chr(34)
End Function


"Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
What statement instantiates objSMail?

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
news:Hfzqb.94247$275.262182@attbi_s53...
> Did you restart Outlook after changing the macro security setting to Low?
> >I thought I did... I did restart again and my Hello World worked.

> Now I am getting
> run-time error '424':
> Object required
> and debug puts me at
> For Each objSRecip In objSMail.Recipients
> objSMail.Recipients = nothing when I place my mouse over it.
>
> Thanks
> Bruce
>
>
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> Did you restart Outlook after changing the macro security setting to Low?

If
> so, does any other VBA code run? Write a "hello world" MsgBox routine if

you
> need something to test. Did you try putting a breakpoint in the

Application_
> ItemSend() event handler?
>
> You can make a basic check of whether there's a problem with Redemption by
> looking at Tools | Options | Other | Advanced Options | Addin Manager. It
> should appear there.
>
> > Also, how whould I change the contact address book to work with? Would I
> > change the line
> >
> > Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> >
> > To something like Set colContacts = “NewAddressBook”

>
> Contacts folders and address books are *not* the same thing, so I'm not

sure
> what you're getting at.
> --
> Sue Mosher, Outlook MVP
> Outlook and Exchange solutions at http://www.slipstick.com
> Author of
> Microsoft Outlook Programming: Jumpstart
> for Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> news:e2yqb.92080$mZ5.603450@attbi_s54...
> > I D/L redemption, and installed it. I then tried to register it in VB (I
> > have 2 entries for SafeOutlookLibrary and both point to redemption.dll)

> When
> > I restarted OL 2002, I got an error that it could not find extend.dat

(or
> > extra.dat if I look in event log. I THOUGHT it said extend.dat ) (I

> cleared
> > the message, as I thought I would be able to get it again by restarting

> O/L-
> > I have not been able to get the error again….)
> >
> > I have pressed ALT-11, starting the VBA editor, and then browsed to
> > ThisOutlookSession and pasted the whole code section there. I have since
> > moved all but the first section into a diff module.
> >
> > I then tried to run it by creating a new email to a address that was not

> in
> > the contacts folder. I did not get any response. I then put a msgbox in

> the
> > code, expecting it to pop the message box, it did not. I am NOT familiar
> > with O/L for VBA, but I have done some in EXCEL, so it SHOULD be

similair…
> >
> > I have not tried any other VBA code. I have not had any need for it.

what
> > would be a good one to just test something?
> >
> > I have signed the code with selfcert and I have also put security to

LOW.
> >
> > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > Did you check your macro security settings -- Tools | Macro | Security?

> Does
> > other VBA code run?
> >
> > If you're using Excel to send out the mail, then you should be able to

> adapt
> > the code I provided to add the same functionality (checking addresses

and
> > creating contacts) to your Excel routines.
> >
> > "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> > news:M3vqb.128842$HS4.1023070@attbi_s01...
> > >
> > > Thanks for the link!
> > > I tried the code, but, it did not work....
> > > I even put a msgbox inthe code so I could see if it was getting to the

> > code.
> > > It is not. I did put it in the correct folder, as per the

instructions.
> > >
> > > Back to the origianal issue...
> > >
> > > Now, is there a way, I can do something similar from EXCEL? I use the

> VBA
> > to
> > > send out all of the email I am actually looking for. All of the email

I
> > send
> > > out of OL, I don't need to put into the fold, as I do not need to

follow
> > > their email perse. Or does it need to be called from Outlook?
> > >
> > > "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > Great, Bruce. You might find this code useful, too:
> > > http://www.slipstick.com/contacts/addauto.htm

>
>



 
Reply With Quote
 
BruceJ
Guest
Posts: n/a
 
      11-07-2003
Sue,
Am I doing this correctly? How would I use the getfolder() within the
function AddRecipToContacts to set the desired contact folder (it is on the
root of my Personal Folders) so I thought it should be "personal
folders/BPConstacts"

' Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
Set colContacts = GetFolder("Personal Folders\BPContacts").Items
I get an error13 Type mismatch

If I do
Set colContacts = GetFolder("BPContacts").Items
I get a run time error 91 object varible or With block varible not set

I am doing this wrong? I must be...

Thanks
Bruce




"Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
To get a non-default folder, you need to walk the folder hierarchy using the
Folders collections or use a function that does that for you. See
http://www.slipstick.com/dev/code/getfolder.htm

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
news:Oqzqb.95807$9E1.459957@attbi_s52...
> Sorry to be a pest <grin>
>
> If I wanted it to add the contact info into a diff folder, would I change
> the
> Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> to
> Set colContacts = "MyContactFolderNameHere"
> If not, how would I cahnge the folder?
> thanks
>



 
Reply With Quote
 
Sue Mosher [MVP]
Guest
Posts: n/a
 
      11-07-2003
It's almost always better in Outlook to get objects one at a time before using their properties, e.g.

Set objFolder = GetFolder("Personal Folders\BPContacts")
If Not objFolder Is Nothing Then
Set colContacts = objFolder.Items
Else
MsgBox "Could not get a MAPIFolder object for Personal Folders\BPContacts"
End If

How did you declare colContacts?

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message news:kVEqb.97707$9E1.471330@attbi_s52...
> Sue,
> Am I doing this correctly? How would I use the getfolder() within the
> function AddRecipToContacts to set the desired contact folder (it is on the
> root of my Personal Folders) so I thought it should be "personal
> folders/BPConstacts"
>
> ' Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> Set colContacts = GetFolder("Personal Folders\BPContacts").Items
> I get an error13 Type mismatch
>
> If I do
> Set colContacts = GetFolder("BPContacts").Items
> I get a run time error 91 object varible or With block varible not set
>


 
Reply With Quote
 
BruceJ
Guest
Posts: n/a
 
      11-07-2003
Getting closer!!! Now, it seems to be finding the record (if present) but it
is adding it to the default olContactItem.
How can I tell what GetFolder is finding? Is there a way to display the
value? And what SHOULD it look like Iif I am calling the directory the right
name?

Also, in the portion that adds the contact:
If objContact Is Nothing Then
MsgBox "Adding ..."
Set objContact = Application.CreateItem(olContactItem)
With objContact
.FullName = objSRecip.Name
.Email1Address = strAddress
.Save
End With
End If

how do I force a location for the item?
below is the module as it stands.
Thanks
Bruce
------------------------

Sub AddRecipToContacts(objMail As MailItem)
Dim strFind As String
Dim strAddress As String
Dim objSMail As Redemption.SafeMailItem
Dim objSRecip As Redemption.SafeRecipient
Dim objNS As NameSpace
Dim colContacts As Items
Dim objContact As ContactItem
Dim i As Integer

' process message recipients
Set objSMail = CreateObject("Redemption.SafeMailItem")
objMail.Save
objSMail.Item = objMail
Set objNS = Application.GetNamespace("MAPI")
'Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
Set objFolder = GetFolder("Personal Folders\BPContacts")
If Not objFolder Is Nothing Then
Set colContacts = objFolder.Items
MsgBox "Got info for Personal Folders\BPContacts"
If Not colContacts Is Nothing Then
MsgBox "colcontacts has value"
Else
MsgBox "colcontacts is empty"
Stop
End If


Else
MsgBox "Could not get a MAPIFolder object for Personal
Folders\BPContacts"
End If


For Each objSRecip In objSMail.Recipients
' check to see if the recip is already in Contacts
strAddress = objSRecip.Address
For i = 1 To 3
strFind = "[Email" & i & "Address] = " & _
AddQuote(strAddress)
Set objContact = colContacts.Find(strFind)
'Stop
If Not objContact Is Nothing Then
Stop
Exit For
End If
Next
Stop
' if not, add it
If objContact Is Nothing Then
MsgBox "Adding ..."
Set objContact = Application.CreateItem(olContactItem)
With objContact
.FullName = objSRecip.Name
.Email1Address = strAddress
.Save
End With
End If
'Stop
Set objContact = Nothing
Next

Set objSMail = Nothing
Set objSRecip = Nothing
Set objNS = Nothing
Set colContacts = Nothing
End Sub
"Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
It's almost always better in Outlook to get objects one at a time before
using their properties, e.g.

Set objFolder = GetFolder("Personal Folders\BPContacts")
If Not objFolder Is Nothing Then
Set colContacts = objFolder.Items
Else
MsgBox "Could not get a MAPIFolder object for Personal
Folders\BPContacts"
End If

How did you declare colContacts?

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
news:kVEqb.97707$9E1.471330@attbi_s52...
> Sue,
> Am I doing this correctly? How would I use the getfolder() within the
> function AddRecipToContacts to set the desired contact folder (it is on

the
> root of my Personal Folders) so I thought it should be "personal
> folders/BPConstacts"
>
> ' Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> Set colContacts = GetFolder("Personal Folders\BPContacts").Items
> I get an error13 Type mismatch
>
> If I do
> Set colContacts = GetFolder("BPContacts").Items
> I get a run time error 91 object varible or With block varible not set
>



 
Reply With Quote
 
BruceJ
Guest
Posts: n/a
 
      11-07-2003
I figured it out! I am using
Set objContact = objFolder.Items.Add(olContactItem)
Now... I just need to figure out the name for the fields and stuff those
with the info I need!

Thanks!

Bruce

"BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
news:lRPqb.98373$mZ5.638456@attbi_s54...
> Getting closer!!! Now, it seems to be finding the record (if present) but

it
> is adding it to the default olContactItem.
> How can I tell what GetFolder is finding? Is there a way to display the
> value? And what SHOULD it look like Iif I am calling the directory the

right
> name?
>
> Also, in the portion that adds the contact:
> If objContact Is Nothing Then
> MsgBox "Adding ..."
> Set objContact = Application.CreateItem(olContactItem)
> With objContact
> .FullName = objSRecip.Name
> .Email1Address = strAddress
> .Save
> End With
> End If
>
> how do I force a location for the item?
> below is the module as it stands.
> Thanks
> Bruce
> ------------------------
>
> Sub AddRecipToContacts(objMail As MailItem)
> Dim strFind As String
> Dim strAddress As String
> Dim objSMail As Redemption.SafeMailItem
> Dim objSRecip As Redemption.SafeRecipient
> Dim objNS As NameSpace
> Dim colContacts As Items
> Dim objContact As ContactItem
> Dim i As Integer
>
> ' process message recipients
> Set objSMail = CreateObject("Redemption.SafeMailItem")
> objMail.Save
> objSMail.Item = objMail
> Set objNS = Application.GetNamespace("MAPI")
> 'Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> Set objFolder = GetFolder("Personal Folders\BPContacts")
> If Not objFolder Is Nothing Then
> Set colContacts = objFolder.Items
> MsgBox "Got info for Personal Folders\BPContacts"
> If Not colContacts Is Nothing Then
> MsgBox "colcontacts has value"
> Else
> MsgBox "colcontacts is empty"
> Stop
> End If
>
>
> Else
> MsgBox "Could not get a MAPIFolder object for Personal
> Folders\BPContacts"
> End If
>
>
> For Each objSRecip In objSMail.Recipients
> ' check to see if the recip is already in Contacts
> strAddress = objSRecip.Address
> For i = 1 To 3
> strFind = "[Email" & i & "Address] = " & _
> AddQuote(strAddress)
> Set objContact = colContacts.Find(strFind)
> 'Stop
> If Not objContact Is Nothing Then
> Stop
> Exit For
> End If
> Next
> Stop
> ' if not, add it
> If objContact Is Nothing Then
> MsgBox "Adding ..."
> Set objContact = Application.CreateItem(olContactItem)
> With objContact
> .FullName = objSRecip.Name
> .Email1Address = strAddress
> .Save
> End With
> End If
> 'Stop
> Set objContact = Nothing
> Next
>
> Set objSMail = Nothing
> Set objSRecip = Nothing
> Set objNS = Nothing
> Set colContacts = Nothing
> End Sub
> "Sue Mosher [MVP]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> It's almost always better in Outlook to get objects one at a time before
> using their properties, e.g.
>
> Set objFolder = GetFolder("Personal Folders\BPContacts")
> If Not objFolder Is Nothing Then
> Set colContacts = objFolder.Items
> Else
> MsgBox "Could not get a MAPIFolder object for Personal
> Folders\BPContacts"
> End If
>
> How did you declare colContacts?
>
> --
> Sue Mosher, Outlook MVP
> Outlook and Exchange solutions at http://www.slipstick.com
> Author of
> Microsoft Outlook Programming: Jumpstart
> for Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
> "BruceJ" <oe*NOSPAM*@connecting4income.com> wrote in message
> news:kVEqb.97707$9E1.471330@attbi_s52...
> > Sue,
> > Am I doing this correctly? How would I use the getfolder() within the
> > function AddRecipToContacts to set the desired contact folder (it is on

> the
> > root of my Personal Folders) so I thought it should be "personal
> > folders/BPConstacts"
> >
> > ' Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
> > Set colContacts = GetFolder("Personal Folders\BPContacts").Items
> > I get an error13 Type mismatch
> >
> > If I do
> > Set colContacts = GetFolder("BPContacts").Items
> > I get a run time error 91 object varible or With block varible not set
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
macros-loop? calling macros X times? Andrew Arro C Programming 2 07-24-2004 09:52 AM
Explanation of macros; Haskell macros mike420@ziplip.com Python 80 11-07-2003 02:22 AM
Re: Explanation of macros; Haskell macros Michael T. Babcock Python 0 11-03-2003 01:54 PM
Re: Explanation of macros; Haskell macros mike420@ziplip.com Python 5 11-01-2003 01:09 AM
Re: Explanation of macros; Haskell macros mike420@ziplip.com Python 1 10-07-2003 04:07 PM



Advertisments