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

Write data into ContactItem field

 
   Home -> Office -> Programming VBA RSS
Next:  How do I convert an Excel template to an Outlook ..  
Author Message
TS Lim

External


Since: Aug 15, 2008
Posts: 8



(Msg. 1) Posted: Fri Aug 15, 2008 8:31 pm
Post subject: Write data into ContactItem field
Archived from groups: microsoft>public>outlook>program_vba (more info?)

After finding a contact item, is it possible to write data into another field
of the item ?
In the example below, after finding the item with the CustomerID field. It
try to write data into the Spouse field. Is it the right way to do it ? It
not, kindly advsie a way where I can write data into the fields of item
selected.

Dim myOlApp As New Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Folder
Dim myItem As Outlook.ContactItem

Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")

myItem.Spouse = "Mrs ID000001"

myItem.Save


Your advise is appreciated.

Thank you.

TS Lim
Back to top
Login to vote
Sue Mosher [MVP-Outlook]

External


Since: Jun 18, 2004
Posts: 613



(Msg. 2) Posted: Fri Aug 15, 2008 9:29 pm
Post subject: RE: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yes, that's it exactly.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx



"TS Lim" wrote:

> After finding a contact item, is it possible to write data into another field
> of the item ?
> In the example below, after finding the item with the CustomerID field. It
> try to write data into the Spouse field. Is it the right way to do it ? It
> not, kindly advsie a way where I can write data into the fields of item
> selected.
>
> Dim myOlApp As New Outlook.Application
> Dim myNamespace As Outlook.NameSpace
> Dim myContacts As Outlook.Folder
> Dim myItem As Outlook.ContactItem
>
> Set myNamespace = myOlApp.GetNamespace("MAPI")
> Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
>
> myItem.Spouse = "Mrs ID000001"
>
> myItem.Save
>
>
> Your advise is appreciated.
>
> Thank you.
>
> TS Lim
Back to top
Login to vote
Dmitry Streblechenko

External


Since: Nov 23, 2003
Posts: 1142



(Msg. 3) Posted: Fri Aug 15, 2008 9:41 pm
Post subject: Re: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Looks fine to me. Does it work for you?
You might want to check that myItem is not Nothing first.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"TS Lim" <TSLim.DeleteThis@discussions.microsoft.com> wrote in message
news:C8E5AE5D-2628-440E-9604-C997A0BE4970@microsoft.com...
> After finding a contact item, is it possible to write data into another
> field
> of the item ?
> In the example below, after finding the item with the CustomerID field. It
> try to write data into the Spouse field. Is it the right way to do it ?
> It
> not, kindly advsie a way where I can write data into the fields of item
> selected.
>
> Dim myOlApp As New Outlook.Application
> Dim myNamespace As Outlook.NameSpace
> Dim myContacts As Outlook.Folder
> Dim myItem As Outlook.ContactItem
>
> Set myNamespace = myOlApp.GetNamespace("MAPI")
> Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
>
> myItem.Spouse = "Mrs ID000001"
>
> myItem.Save
>
>
> Your advise is appreciated.
>
> Thank you.
>
> TS Lim
Back to top
Login to vote
TS Lim

External


Since: Aug 15, 2008
Posts: 8



(Msg. 4) Posted: Sat Aug 16, 2008 12:03 am
Post subject: Re: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Dear Dmitry,

I tried to run it, but it does not work.

TS Lim


"Dmitry Streblechenko" wrote:

> Looks fine to me. Does it work for you?
> You might want to check that myItem is not Nothing first.
>
> --
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
> -
> "TS Lim" <TSLim RemoveThis @discussions.microsoft.com> wrote in message
> news:C8E5AE5D-2628-440E-9604-C997A0BE4970@microsoft.com...
> > After finding a contact item, is it possible to write data into another
> > field
> > of the item ?
> > In the example below, after finding the item with the CustomerID field. It
> > try to write data into the Spouse field. Is it the right way to do it ?
> > It
> > not, kindly advsie a way where I can write data into the fields of item
> > selected.
> >
> > Dim myOlApp As New Outlook.Application
> > Dim myNamespace As Outlook.NameSpace
> > Dim myContacts As Outlook.Folder
> > Dim myItem As Outlook.ContactItem
> >
> > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> > Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
> >
> > myItem.Spouse = "Mrs ID000001"
> >
> > myItem.Save
> >
> >
> > Your advise is appreciated.
> >
> > Thank you.
> >
> > TS Lim
>
>
>
Back to top
Login to vote
TS Lim

External


Since: Aug 15, 2008
Posts: 8



(Msg. 5) Posted: Sat Aug 16, 2008 12:06 am
Post subject: RE: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

After finding the item, I can read data of fields of the item. But to write
data, it still does not work. Any advise ?

TS Lim


"Sue Mosher [MVP-Outlook]" wrote:

> Yes, that's it exactly.
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook Programming: Jumpstart
> for Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
>
> "TS Lim" wrote:
>
> > After finding a contact item, is it possible to write data into another field
> > of the item ?
> > In the example below, after finding the item with the CustomerID field. It
> > try to write data into the Spouse field. Is it the right way to do it ? It
> > not, kindly advsie a way where I can write data into the fields of item
> > selected.
> >
> > Dim myOlApp As New Outlook.Application
> > Dim myNamespace As Outlook.NameSpace
> > Dim myContacts As Outlook.Folder
> > Dim myItem As Outlook.ContactItem
> >
> > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> > Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
> >
> > myItem.Spouse = "Mrs ID000001"
> >
> > myItem.Save
> >
> >
> > Your advise is appreciated.
> >
> > Thank you.
> >
> > TS Lim
Back to top
Login to vote
Sue Mosher [MVP-Outlook]

External


Since: Jun 18, 2004
Posts: 613



(Msg. 6) Posted: Sat Aug 16, 2008 7:34 am
Post subject: RE: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

What specifically doesn't work? Error messages? Other symptoms? Does myItem
return the correct object?
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx



"TS Lim" wrote:

> After finding the item, I can read data of fields of the item. But to write
> data, it still does not work. Any advise ?
>
> TS Lim
>
>
> "Sue Mosher [MVP-Outlook]" wrote:
>
> > Yes, that's it exactly.

> >
> > "TS Lim" wrote:
> >
> > > After finding a contact item, is it possible to write data into another field
> > > of the item ?
> > > In the example below, after finding the item with the CustomerID field. It
> > > try to write data into the Spouse field. Is it the right way to do it ? It
> > > not, kindly advsie a way where I can write data into the fields of item
> > > selected.
> > >
> > > Dim myOlApp As New Outlook.Application
> > > Dim myNamespace As Outlook.NameSpace
> > > Dim myContacts As Outlook.Folder
> > > Dim myItem As Outlook.ContactItem
> > >
> > > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > > Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> > > Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
> > >
> > > myItem.Spouse = "Mrs ID000001"
> > >
> > > myItem.Save
> > >
> > >
> > > Your advise is appreciated.
> > >
> > > Thank you.
> > >
> > > TS Lim
Back to top
Login to vote
TS Lim

External


Since: Aug 15, 2008
Posts: 8



(Msg. 7) Posted: Sat Aug 16, 2008 8:24 am
Post subject: RE: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

When I run the sub procedure, no error message was prompted, and when
checking with my outlook folder, the Spouse field was not updated.

I try to check by adding 2 msgbox as show below. When the procedure is run,
Test 1 message box prompted, but Test 2 message box does not prompt. Looks
like the procedure stop running at the line 'myItem.Spouse = "Mrs ID000001"'

Dim myOlApp As New Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myContacts As Outlook.Folder
Dim myItem As Outlook.ContactItem

Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")

Msgbox "Test 1 on whether procedure run until here"

myItem.Spouse = "Mrs ID000001"

Msgbox "Test 2 on wheterh procedure run until here"

myItem.Save



"Sue Mosher [MVP-Outlook]" wrote:

> What specifically doesn't work? Error messages? Other symptoms? Does myItem
> return the correct object?
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook Programming: Jumpstart
> for Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
>
> "TS Lim" wrote:
>
> > After finding the item, I can read data of fields of the item. But to write
> > data, it still does not work. Any advise ?
> >
> > TS Lim
> >
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> > > Yes, that's it exactly.
>
> > >
> > > "TS Lim" wrote:
> > >
> > > > After finding a contact item, is it possible to write data into another field
> > > > of the item ?
> > > > In the example below, after finding the item with the CustomerID field. It
> > > > try to write data into the Spouse field. Is it the right way to do it ? It
> > > > not, kindly advsie a way where I can write data into the fields of item
> > > > selected.
> > > >
> > > > Dim myOlApp As New Outlook.Application
> > > > Dim myNamespace As Outlook.NameSpace
> > > > Dim myContacts As Outlook.Folder
> > > > Dim myItem As Outlook.ContactItem
> > > >
> > > > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > > > Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> > > > Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
> > > >
> > > > myItem.Spouse = "Mrs ID000001"
> > > >
> > > > myItem.Save
> > > >
> > > >
> > > > Your advise is appreciated.
> > > >
> > > > Thank you.
> > > >
> > > > TS Lim
Back to top
Login to vote
TS Lim

External


Since: Aug 15, 2008
Posts: 8



(Msg. 8) Posted: Sat Aug 16, 2008 8:44 am
Post subject: RE: Write data into ContactItem field [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Dear Sue,

Pls ignore my reply earlier on your question below. It is working now. Thank
you a lot for your prompt and precise reply.

Regards,

TS Lim



"Sue Mosher [MVP-Outlook]" wrote:

> What specifically doesn't work? Error messages? Other symptoms? Does myItem
> return the correct object?
> --
> Sue Mosher, Outlook MVP
> Author of Microsoft Outlook Programming: Jumpstart
> for Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
>
> "TS Lim" wrote:
>
> > After finding the item, I can read data of fields of the item. But to write
> > data, it still does not work. Any advise ?
> >
> > TS Lim
> >
> >
> > "Sue Mosher [MVP-Outlook]" wrote:
> >
> > > Yes, that's it exactly.
>
> > >
> > > "TS Lim" wrote:
> > >
> > > > After finding a contact item, is it possible to write data into another field
> > > > of the item ?
> > > > In the example below, after finding the item with the CustomerID field. It
> > > > try to write data into the Spouse field. Is it the right way to do it ? It
> > > > not, kindly advsie a way where I can write data into the fields of item
> > > > selected.
> > > >
> > > > Dim myOlApp As New Outlook.Application
> > > > Dim myNamespace As Outlook.NameSpace
> > > > Dim myContacts As Outlook.Folder
> > > > Dim myItem As Outlook.ContactItem
> > > >
> > > > Set myNamespace = myOlApp.GetNamespace("MAPI")
> > > > Set myContacts = myNamespace.GetDefaultFolder(olFolderContacts)
> > > > Set myItem = myContacts.Items.Find("[CustomerID] = ""ID0000001""")
> > > >
> > > > myItem.Spouse = "Mrs ID000001"
> > > >
> > > > myItem.Save
> > > >
> > > >
> > > > Your advise is appreciated.
> > > >
> > > > Thank you.
> > > >
> > > > TS Lim
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
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support