Solved

Create new contact on specific form

Posted on 2011-09-13
18
263 Views
Last Modified: 2012-05-12
Hello all

I just add this new code on my project.

Then, i have created a new form for adding new contact, and then put it has default.

But when i use this code, it does not appy on my new default form. I takes the one that was in default before.

My new form name is "TEST FORM".

Where do i modify the code so that it use the new form?

Thanks again for your help.


   Private Sub CréerNouveauClientToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CréerNouveauClientToolStripMenuItem.Click
        Dim oApp As Outlook.Application
        oApp = CreateObject("Outlook.Application")

        Dim oNs As Outlook.NameSpace
        oNs = oApp.GetNamespace("MAPI")
        oNs.Logon()

        Dim oItem As Outlook.ContactItem
        oItem = oApp.CreateItem(OlItemType.olContactItem)

        With oItem
            .FullName = "AuthorCode"
            .CompanyName = "AuthorCODE"
            .Email1Address = "contactus@authorcode.com"
            .JobTitle = "Developer"
            .HomeAddress = "Delhi,India"
            .BusinessAddress = "Delhi,India"
            .Email1Address = "supoerttools@authorcode.com"
        End With
        oItem.Save()

        MsgBox("Sauvegarder")
    End Sub

Open in new window

0
Comment
Question by:Wilder1626
  • 11
  • 6
18 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 36530436
I'm not sure I understand the problem, but perhaps you haven't updated the Handles clause?

Private Sub CréerNouveauClientToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CréerNouveauClientToolStripMenuItem.Click
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36530490
Sorry, i will try to give more details.

When you want to manually enter a new contact in Microsoft Outlook 2007, there is a form for that.

Since i did not like that form for adding a new contact, i decided to create a custom one, with only the fields i need.

Ex:

Full name
Telephone
cell
Address
City
Province
Postal code
Email......

After that, i when into the Contact properties and i applied the new custom contact form by default.

Now, if i create a new contact directly in Outlook, i see my new form.

But the problem i have now, it is to fix my vb.net code so that when i create a new contact, directly in my project.net, that it will send the information in my new custom form.

Now, what it's doing, it is sending the information on the previous form.

Does it make sense?

Please let me know.

Thanks again.
0
 
LVL 40
ID: 36530649
Wilder.

Instead of using .NET to control an Outlook form, why don't you create a Form in .NET and use the content of that form to add the new Contact to Outlook. Seems to me that it would make things easier, since you can do a lot more in a .NET form than in an Outlook form.

If you need to stick to the Outlook form for some reason, there are great chances that somebody who know about those would be better suited to give you a proper answer than somebody who is good in VB.NET. I would also post this in an Outlook, VBA.Outlook or VBA.Office forum. The answer you would get there should then be easyly applied to your .NET code.

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36530697
Hello JamesBurger

I have already created a Form in .NET.

But i need to be able to split the address files since by default, in the official master contact form from Outlook, they are all in the same textbox.

This is the form i have created: See picture.


Is there another way in vb.net to separate the address fields?

add-contact.net.jpg
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36530781
Sorry, i wanted to say: But i need to be able to split the address fields since by default, in the official master contact form from Outlook, they are all in the same textbox.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36530901
And is the sauverder button, i would have a code like this:

  Dim oApp As Outlook.Application
        oApp = CreateObject("Outlook.Application")

        Dim oNs As Outlook.NameSpace
        oNs = oApp.GetNamespace("MAPI")
        oNs.Logon()

        Dim oItem As Outlook.ContactItem
        oItem = oApp.CreateItem(OlItemType.olContactItem)

        With oItem
            .FullName = Me.nom_prenom.Text
            .ville_domicile = Me.ville.Text
            .Email1Address = Me.courriel.Text
            .postal_code = Me.code_postal.Text
        End With
        oItem.Save()


        'Transfert contact to form 2
        Form2.client.Text = Me.nom_prenom.Text
        Form2.courriel.Text = Me.courriel.Text
        Form2.address.Text = Me.adresse_residentiel.Text
        Form2.ville.Text = Me.ville.Text
        Form2.telephone.Text = Me.telephone.Text
        Form2.code_postal.Text = Me.code_postal.Text
        Me.Close()



        MsgBox("Sauvegarder")

Open in new window

0
 
LVL 40
ID: 36531032
There seems to be many different problems in different posts. And different forms too, a custom one in Outlook and one in .NET.

Let's try to make things clear.

-----

"it is sending the information on the previous form."

We do not see any form in your code. What form? Your .NET form or your custom Outlook form? How do you display, hide, close the form. The problem is probably there somewhere.

-----

"'i need to be able to split the address files since by default, in the official master contact form from Outlook, they are all in the same textbox"

When you type the address in Outlook, it comes out as one String, but ends up in different fields in the Contact information (BusinessAddress, BusinessAddressCity and so on).

You want to do the same thing in .NET, do I understand well?

If so, Bonne chance pour celle-là (good luck on that one).

The algorithm to do that would be very complex. Here are just a few clues.

You first need to separate the lines. This one is easy, with the Split method of the String class.

It's after that that it gets complex, because not 2 users will type the filed the same way (no matter if you insist on a given format). Here are just a few of the things to consider.

Sometimes theres is a coma between the street number, sometimes not.
Sometimes the city, province/state and postal/zip code are on one line, sometimes on 2, sometimes on 3.
State or province might be a word or the code, and some of them can have many forms (Québec, Quebec, QC, PQ).
In Canada, the province is sometimes in enclosed between parenthesis, sometimes not.
And i could go on for a while.

You might try to find an algorithm to do that, but it would never be OK. The one in Outlook often makes mistakes.

The way you are getting the address in the .NET form you sent us is a lot better, believe me.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36531139
Ok, so i will continue to use the form i did, i just need to look how i will be able to transfer all the testbox in each fields in outlook.

I will forget about the custom form in Outlook.

I will also search how to name the oItem fields

These worke:
  With oItem
            .FullName = Me.nom_prenom.Text
            .Email1Address = Me.courriel.Text
        End With

But i need to find the rest.

I will do some googling see if i found something.
0
 
LVL 40
ID: 36531263
You do not need to "search" for the other fields. Don't you get the list of fields when you type "oItem." and stop there? They are all there.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 11

Author Comment

by:Wilder1626
ID: 36531355
But how will it know where to send the textbox text tothe right place in oItem?

Ex:
.FullName = Me.nom_prenom.Text
            .Email1Address = Me.courriel.Text

It send the Me.nom_prenom.Text in the FullName field.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36531559
Either you split the name entry in 2 entries, txtPrénom and txtNom and go this way:

.FirstName = txtPrénom.Text
.LastName = txtNom.Text

Don't you see those 2 fields in the IntelliSense list?

Or you send what you have now to .FullName, as you do in your last piece of code, and let Outlook do the split as it does usually, that means OK if they are in 2 words, but a mess if they are in more than 2 words.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36531717
For the name, i was sending  in full name. But that is ok.

Where i block is for these fields: address / City / Postal code / Province.


Where exactly do i find this IntelliSense list.

i have extract from outlook all fileds but if i use the heaaders, it does noy work:


ex:
'Ruedomicile
'Villedomicile
'DépRégiondomicile
'Codepostaldomicile

This is the portin where i think i don't understand to much.

If i google IntelliSense list, it does not say a lot.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36531735
oh, i think i understand.

Let me try something
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36531801
Ohhhh! Got it now.

Thanks for your patience with me. Once i understand, it help. :-)

 With oItem
            'Full name
            .FullName = Me.nom_prenom.Text

            'Home Address
            .HomeAddressStreet = Me.adresse_residentiel.Text

            'Home City
            .HomeAddressCity = Me.ville.Text

            'Home Province
            .HomeAddressState = Me.province.Text

            'Home Postal code
            .HomeAddressPostalCode = Me.code_postal.Text

            'Home Téléphone
            .HomeTelephoneNumber = Me.telephone.Text

            'Home cell
            .Home2TelephoneNumber = Me.cellulaire.Text

            'Email address
            .Email1Address = Me.courriel.Text

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 36531826
Thanks again for your patience with me. I really appreciate your help all the time.

When i do it once, i remember. :-P
0
 
LVL 40
ID: 36531889
My job is to teach the stuff.

So patience is my job.

Think what it is when I am in a classroom with 12 programmers that all have different needs and backgrounds.

Helping you is a charm, because you want to learn and do not give up.

Et je ne vois pas souvent des champs Prénom et Nom sur ce site (I do not see French labels often on this site). Saint-Basile (if I remember well) and Longueuil are not too far apart. I am always glad to help a neighbour.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 36532793
Since i work in Boucherville also, it's bout 10 minutes from St-Basile. So to Longueuil about 5 minutes more. So it is very not to far apart.

Thanks again to you.

I will probably go for now vb.net training. That will surly help me more.
0
 
LVL 40
ID: 36532855
If .NET is part of your work, training will help a lot. I have people in my class that have been at it for a few years and find out that a lot of what they where doing was wrong or could have been a lot simpler.

Maybe I will have the chance to have you in my class one of these days (Cours VB.NET)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now