Results 1 to 36 of 36

Thread: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Question extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    how do i extract email id , name from outlook email and transfer it to contacts in outlook.

    how do i use the vb editor in outlook to perform this task.

    i would like to create a button , which upon pressing exports the email id, name (from an email) to contacts.

    kindly help
    Last edited by indiewolf; Jun 28th, 2006 at 10:14 AM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    ok i have tried using robdog888 solution to one of the problems here.


    this is the code but kindly lemmo know what i do to add email id and name of the sender as i press the "save to contacts" from "tool"


    there are changes to be made in the oSaveAs_Click event.

    VB Code:
    1. Option Explicit
    2. 'Behind ThisOutlookSession
    3. Private oCBTools As Office.CommandBarPopup
    4. Private oCBSaveMe As Office.CommandBarButton
    5.  
    6. Public WithEvents oSaveAs As Office.CommandBarButton
    7.  
    8. Private Sub SyncButton(btn As Office.CommandBarButton)
    9.     Set oSaveAs = btn
    10.     If btn Is Nothing Then
    11.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    12.     End If
    13. End Sub
    14.  
    15. Private Sub Application_MAPILogonComplete()
    16.     Set oCBTools = Application.ActiveExplorer.CommandBars("Menu Bar").Controls("&Tools")
    17.     Set oCBSaveMe = Application.ActiveExplorer.CommandBars("Menu Bar").FindControl(msoControlButton, 1, "888", True, True)
    18.     If TypeName(oCBSaveMe) = "Nothing" Then
    19.         Set oCBSaveMe = oCBTools.Controls.Add(msoControlButton, 1, "888", , True)
    20.     End If
    21.     With oCBSaveMe
    22.         .BeginGroup = True
    23.         .Caption = "Send to Contacts..."
    24.         .Enabled = True
    25.         .Style = msoControlCustom
    26.         .Tag = "888"
    27.         .Visible = True
    28.     End With
    29.     Call SyncButton(oCBSaveMe)
    30. End Sub
    31.  
    32. Private Sub oSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    33.    
    34.     Dim oSel As Outlook.Selection
    35.     Dim oEmail As Outlook.MailItem
    36.     Dim sSub As String
    37.    
    38.     Set oSel = Application.ActiveExplorer.Selection
    39.     If oSel.Class = olMail Then
    40.         Set oEmail = oSel
    41.         'Use the email subject as the filename
    42.         sSub = oEmail.SenderEmailAddress
    43.        
    44.        
    45.        sSud = oEmail.SenderName
    46.         Outlook.olContact
    47.        
    48.         Set oEmail = Nothing
    49.         MsgBox "Saved"
    50.     End If
    51.     Set oSel = Nothing
    52.    
    53. End Sub


    kindly help
    its urgent
    cheers

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    VB Code:
    1. If oSel.Class = olMail Then
    2.     Set oEmail = oSel
    3.     'Use the email subject as the filename
    4.     sAddy = oEmail.SenderEmailAddress
    5.     sID = oEmail.EntryID
    6.     sFullName = oEmail.FullName
    7.     sSenderName = oEmail.SenderName
    8.     Set oEmail = Nothing
    9.     MsgBox "Saved"
    10. End If
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    hi rob
    first of all many many thanks
    no i was wrong the code is not working at all

    it is not importing the email address or name of any received email to contacts once i click the tools>send to contact
    kindly help
    cheers

    my code now is

    VB Code:
    1. Private Sub oSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    2.    
    3.     Dim oSel As Outlook.Selection
    4.     Dim oEmail As Outlook.MailItem
    5.     Dim sSub As String
    6.     Dim sAddy As String
    7.     Dim sID As String
    8.     Dim sFullName As String
    9.     Dim sSenderName As String
    10.    
    11.     Set oSel = Application.ActiveExplorer.Selection
    12.    
    13.     If oSel.Class = olMail Then
    14.     Set oEmail = oSel
    15.     'Use the email subject as the filename
    16.     sAddy = oEmail.SenderEmailAddress
    17.     sID = oEmail.EntryID
    18.     sFullName = oEmail.FullName
    19.     sSenderName = oEmail.SenderName
    20.     Set oEmail = Nothing
    21.     MsgBox "Saved"
    22. End If
    23.    
    24.     Set oSel = Nothing
    25.    
    26. End Sub
    Last edited by indiewolf; Jun 22nd, 2006 at 10:53 AM.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    Did you make another selection and then reclick on the menu item?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    yes i did
    it is not happening

    it is not adding anything to "outlook contacts"


    kindly help

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    Quote Originally Posted by RobDog888
    Did you make another selection and then reclick on the menu item?

    may i ask where is the code for adding it to outlook contacts?

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    There is none as I thought you had it somewhere else since you were saving the props to variables.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    no i dont have it

    kindly show me how to go about that

    becoz the main function is to import it to the contact which is what i am unable to do

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    VB Code:
    1. Private Sub oSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    2.  
    3.     Dim oSel As Outlook.Selection
    4.     Dim oEmail As Outlook.MailItem
    5.     Dim oContact As Outlook.ContactItem
    6.  
    7.     Set oSel = Application.ActiveExplorer.Selection
    8.     If oSel.Class = olMail Then
    9.         Set oEmail = oSel
    10.         Set oContact = Application.CreateItem(olContactItem)
    11.         With oContact
    12.             .Subject = oEmail.Subject
    13.             .Email1Address = oEmail.SenderEmailAddress
    14.             .FullName = oEmail.SenderName
    15.             .Body = oEmail.Body
    16.             .Save
    17.             .Display
    18.         End With
    19.         MsgBox "Saved"
    20.         Set oEmail = Nothing
    21.         Set oContact = Nothing
    22.     End If
    23.     Set oSel = Nothing
    24.  
    25. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    no it is not working !!


    it is still not exporting anything to the contacts.

    kindly help
    cheers mate

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    Place a breakpoint on the click event. Then step through the code and see where the error is. Does it give an error message?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    Quote Originally Posted by RobDog888
    Place a breakpoint on the click event. Then step through the code and see where the error is. Does it give an error message?
    i did place abreakpoint at the start of private... by pressing f9
    but how do i know where is the error message?
    i did not understand . kindly explain again.
    cheers

    this is how the whole code is
    could you please have a look

    VB Code:
    1. Option Explicit
    2. 'Behind ThisOutlookSession
    3. Private oCBTools As Office.CommandBarPopup
    4. Private oCBSaveMe As Office.CommandBarButton
    5.  
    6. Public WithEvents oSaveAs As Office.CommandBarButton
    7.  
    8. Private Sub SyncButton(btn As Office.CommandBarButton)
    9.     Set oSaveAs = btn
    10.     If btn Is Nothing Then
    11.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    12.     End If
    13. End Sub
    14.  
    15. Private Sub Application_MAPILogonComplete()
    16.     Set oCBTools = Application.ActiveExplorer.CommandBars("Menu Bar").Controls("&Tools")
    17.     Set oCBSaveMe = Application.ActiveExplorer.CommandBars("Menu Bar").FindControl(msoControlButton, 1, "888", True, True)
    18.     If TypeName(oCBSaveMe) = "Nothing" Then
    19.         Set oCBSaveMe = oCBTools.Controls.Add(msoControlButton, 1, "888", , True)
    20.     End If
    21.     With oCBSaveMe
    22.         .BeginGroup = True
    23.         .Caption = "Send to Contacts..."
    24.         .Enabled = True
    25.         .Style = msoControlCustom
    26.         .Tag = "888"
    27.         .Visible = True
    28.     End With
    29.     Call SyncButton(oCBSaveMe)
    30. End Sub
    31.  
    32.  
    33.  
    34.  
    35. Private Sub oSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    36.    
    37.      Dim oSel As Outlook.Selection
    38.     Dim oEmail As Outlook.MailItem
    39.     Dim oContact As Outlook.ContactItem
    40.  
    41.     Set oSel = Application.ActiveExplorer.Selection
    42.     If oSel.Class = olMail Then
    43.         Set oEmail = oSel
    44.         Set oContact = Application.CreateItem(olContactItem)
    45.         With oContact
    46.             .Subject = oEmail.Subject
    47.             .Email1Address = oEmail.SenderEmailAddress
    48.             .FullName = oEmail.SenderName
    49.             .Body = oEmail.Body
    50.             .Save
    51.             .Display
    52.         End With
    53.         MsgBox "Saved"
    54.         Set oEmail = Nothing
    55.         Set oContact = Nothing
    56.     End If
    57.     Set oSel = Nothing
    58.  
    59. End Sub

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    If the code is running then if you had placed a breakpoint on the click event your code will stop there when you click on the menu item. It will be a yellow highlighted line. By pressing F8 you will step through the code. When it errors or ? it will tell you the issue.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    Quote Originally Posted by RobDog888
    If the code is running then if you had placed a breakpoint on the click event your code will stop there when you click on the menu item. It will be a yellow highlighted line. By pressing F8 you will step through the code. When it errors or ? it will tell you the issue.
    thanks much for the above.
    error @ the code below.
    the yellow line follows these lines of code when f8 is pressed.

    VB Code:
    1. Set oSel = Application.ActiveExplorer.Selection
    2.     If oSel.Class = olMail Then
    3.  Set oSel = Nothing
    4.  
    5. End Sub

    cheers

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    kindly help
    still waiting

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    kindly help

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    And what is the error?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    Quote Originally Posted by RobDog888
    And what is the error?
    it doesnt specify the error. only a highlighted yellow line .

    cheers

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    It it on the same line as your breakpoint? If it is then press F8 to increment and ste to the next line of code to be processed. this is the debugging part.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    well i keep on pressing f8 after the yellow line and it moves on the code i specified above..the error one.it highlights the above error code with yellow and that is all it does.

    yes it is on the same line as the breakpoint. oh its so confusing.

    here is the entire code:
    can u copy-paste it in thisoutlooksession as see what is wrong.
    cheers


    VB Code:
    1. Option Explicit
    2. 'Behind ThisOutlookSession
    3. Private oCBTools As Office.CommandBarPopup
    4. Private oCBSaveMe As Office.CommandBarButton
    5.  
    6. Public WithEvents oSaveAs As Office.CommandBarButton
    7.  
    8. Private Sub SyncButton(btn As Office.CommandBarButton)
    9.     Set oSaveAs = btn
    10.     If btn Is Nothing Then
    11.         MsgBox "Sync. of '" & btn.Caption & "' button event failed!", vbCritical + vbOKOnly
    12.     End If
    13. End Sub
    14.  
    15. Private Sub Application_MAPILogonComplete()
    16.     Set oCBTools = Application.ActiveExplorer.CommandBars("Menu Bar").Controls("&Tools")
    17.     Set oCBSaveMe = Application.ActiveExplorer.CommandBars("Menu Bar").FindControl(msoControlButton, 1, "888", True, True)
    18.     If TypeName(oCBSaveMe) = "Nothing" Then
    19.         Set oCBSaveMe = oCBTools.Controls.Add(msoControlButton, 1, "888", , True)
    20.     End If
    21.     With oCBSaveMe
    22.         .BeginGroup = True
    23.         .Caption = "Send to Contacts..."
    24.         .Enabled = True
    25.         .Style = msoControlCustom
    26.         .Tag = "888"
    27.         .Visible = True
    28.     End With
    29.     Call SyncButton(oCBSaveMe)
    30. End Sub
    31.  
    32.  
    33.  
    34.  
    35. Private Sub oSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    36.    
    37.      Dim oSel As Outlook.Selection
    38.     Dim oEmail As Outlook.MailItem
    39.     Dim oContact As Outlook.ContactItem
    40.  
    41.     Set oSel = Application.ActiveExplorer.Selection
    42.     If oSel.Class = olMail Then
    43.         Set oEmail = oSel
    44.         Set oContact = Application.CreateItem(olContactItem)
    45.         With oContact
    46.             .Subject = oEmail.Subject
    47.             .Email1Address = oEmail.SenderEmailAddress
    48.             .FullName = oEmail.SenderName
    49.             .Body = oEmail.Body
    50.             .Save
    51.             .Display
    52.         End With
    53.         MsgBox "Saved"
    54.         Set oEmail = Nothing
    55.         Set oContact = Nothing
    56.     End If
    57.     Set oSel = Nothing
    58.  
    59. End Sub

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    I do not get an error but you are saying you get an error as you step thriugh the code so then what is the nessage disaply?

    This is behind your thisoutlooksession class? You are only selecting one email item?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    i put the breakpoint. close the visualbasic editor. close outlook. again open outlook . select an email message. use the save to contacts... button and it takes me to the highlighted yellow section wherein i put the breakpoint.

    if i dont put a breakpoint and just open outlook , select an email or multiple emails and click save to contacts... from tools> save to contacts.. , i am not able to add any contact email id or name to my contacts.

    i have this code in
    Project1(VbaProject.OTM)>microsoft office outlook>ThisOutlookSession (as nodes in visual basic editor)

    is that the problem? class?

    kindly help
    cheers

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    kindly help
    cheers

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook

    The code is only handling a single email selection so if you select multiple it will cause an error. We can handle multiple selections later.

    The class shouldnt be an issue.

    When you breakpoint with the code do you press F8 and step through it?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    i did everything. i have pasted the code above. and i have pasted the same thing in thisoutlooksession.
    macros are enabled .
    as soon as i start outlook, i select an email, click send to contacs, nothing happens.
    what could be the problem.

    kindly help
    visual basic.net (2008)

    .net framework 3.5


  27. #27

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    i place the breakpoint in the code. press f8 (step into) nothing happens. the cursor remain still.

    it is only after i close outlook and start it again , select email, press send to contacts that it takes me to thisoutlooksession code page...highlights the breakpoint...and then when i click f8 it takes me to the lines(error code) which i had mentioned above.(see posts above)

    these lines are also highlted as yellow..and after pressing f8 until end class the colour disappears the code returns to normalcy. but still does not run.

    what is the next step that i can do? should i paste the code in another module..run ..what ?
    kindly help to get me rid of this problem. its been a week now

    DO I HAVE TO ADD ANY REFERENCES?
    cheers
    Last edited by indiewolf; Jun 28th, 2006 at 06:33 AM.
    visual basic.net (2008)

    .net framework 3.5


  28. #28

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook

    VB Code:
    1. Private Sub oSaveAs_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    2.    
    3.      Dim oSel As Outlook.Selection
    4.     Dim oEmail As Outlook.MailItem
    5.     Dim oContact As Outlook.ContactItem
    6. Dim Item As Outlook.MailItem
    7.     Set oSel = Application.ActiveExplorer.Selection
    8.    For Each Item In oSel
    9.    If Item.Class = olMail Then
    10.     Set oEmail = Item
    11.    
    12.         Set oContact = Application.CreateItem(olContactItem)
    13.        With oContact
    14.             .Subject = oEmail.Subject
    15.             .Email1Address = oEmail.SenderEmailAddress
    16.             .FullName = oEmail.SenderName
    17.             .Body = oEmail.Body
    18.             .Save
    19.             .Display
    20.         End With
    21.         MsgBox "Saved"
    22.         Set oEmail = Nothing
    23.         Set oContact = Nothing
    24.    
    25.     Set oSel = Nothing
    26.  End If
    27. Next
    28. End Sub

    finally i cud solve it. BUT BUT But

    THE ENTRIES IN THE contact list are duplicating! what should i do to avoid that.
    kindly help
    cheers
    visual basic.net (2008)

    .net framework 3.5


  29. #29
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    You will need to search your contacts programmatically to see if a contact already exists. Then either prompt the user that it exists and if they want to overwrite or duplicate or cancel.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  30. #30

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    sorry! how do i go about it?
    could you show me something.

    cheers
    well ihave this code but it has errors as well as it just puts a flag instead of really deleting.
    can u please help
    cheers
    VB Code:
    1. Public Sub deleteduplicatecontacts()
    2. Dim oldcontact As ContactItem, newcontact As ContactItem, j As Integer
    3. Set mynamespace = GetNamespace("MAPI")
    4. Set myfolder = mynamespace.GetDefaultFolder(olFolderConta  cts)
    5. Set myitems = myfolder.Items
    6. myitems.Sort "[File As]", olDescending
    7. totalcount = myitems.Count
    8. j = 1
    9. While ((j < totalcount) And (myitems(j).Class <> olContact))
    10.   j = j + 1
    11. Wend
    12. Set oldcontact = myitems(j)
    13. For i = j + 1 To totalcount
    14.   If (myitems(i).Class = olContact) Then
    15.     Set newcontact = myitems(i)
    16.     'if((newcontact.lastmodificationtime = oldcontact.lastmodificationtime) and
    17.     If ((newcontact.LastNameAndFirstName = oldcontact.LastNameAndFirstName) And _
    18.         (newcontact.FileAs = oldcontact.FileAs) And _
    19.         (newcontact.PagerNumber = oldcontact.PagerNumber) And _
    20.         (newcontact.HomeTelephoneNumber = oldcontact.HomeTelephoneNumber) And _
    21.         (newcontact.BusinessTelephoneNumber = oldcontact.BusinessTelephoneNumber) And _
    22.         (newcontact.BusinessAddress = oldcontact.BusinessAddress) And _
    23.         (newcontact.Email1Address = oldcontact.Email1Address) And _
    24.         (newcontact.HomeAddress = oldcontact.HomeAddress) And _
    25.         (newcontact.CompanyName = oldcontact.CompanyName)) Then
    26.       'use FTPSite as a flag to mark duplicates
    27.       newcontact.FTPSite = "DELETEMESEYMOUR"
    28.       newcontact.Save
    29.     End If
    30.     Set oldcontact = newcontact
    31.  
    32.   End If
    33. Next i
    34. End Sub
    Last edited by indiewolf; Jun 29th, 2006 at 03:40 AM.
    visual basic.net (2008)

    .net framework 3.5


  31. #31

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    VB Code:
    1. Public Sub deleteduplicatecontacts()
    2. Dim oldcontact As ContactItem, newcontact As ContactItem, j As Integer
    3. Dim mynamespace As NameSpace
    4. Dim myitems As Items
    5. Dim myfolder As Folders
    6. Dim i As Integer
    7. Dim totalcount As Integer
    8.  
    9. Set mynamespace = GetNamespace("MAPI")
    10.  
    11. Set myfolder = mynamespace.GetDefaultFolder(olFolderContacts)
    12. Set myitems = myfolder.Items
    13. myitems.Sort "[File As]", olDescending
    14. totalcount = myitems.Count
    15. j = 1
    16. While ((j < totalcount) And (myitems(j).Class <> olContact))
    17.   j = j + 1
    18. Wend
    19. Set oldcontact = myitems(j)
    20. 'For i = j + 1 To totalcount
    21. For i = totalcount To (j + 1) Step -1
    22.  
    23.   If (myitems(i).Class = olContact) Then
    24.     Set newcontact = myitems(i)
    25.     'if((newcontact.lastmodificationtime = oldcontact.lastmodificationtime) and
    26.     If ((newcontact.LastNameAndFirstName = oldcontact.LastNameAndFirstName) And _
    27.         (newcontact.FileAs = oldcontact.FileAs) And _
    28.         (newcontact.PagerNumber = oldcontact.PagerNumber) And _
    29.         (newcontact.HomeTelephoneNumber = oldcontact.HomeTelephoneNumber) And _
    30.         (newcontact.BusinessTelephoneNumber = oldcontact.BusinessTelephoneNumber) And _
    31.         (newcontact.BusinessAddress = oldcontact.BusinessAddress) And _
    32.         (newcontact.Email1Address = oldcontact.Email1Address) And _
    33.         (newcontact.HomeAddress = oldcontact.HomeAddress) And _
    34.         (newcontact.CompanyName = oldcontact.CompanyName)) Then
    35.       'use FTPSite as a flag to mark duplicates
    36.       newcontact.Delete  
    37.       newcontact.Save
    38.     End If
    39.     Set oldcontact = newcontact
    40.  
    41.   End If
    42. Next i
    43. End Sub

    kindly help
    type mismatch error

    kindly help
    visual basic.net (2008)

    .net framework 3.5


  32. #32

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    kindly help, code above.
    cheers
    visual basic.net (2008)

    .net framework 3.5


  33. #33
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    Why are you doing this?
    VB Code:
    1. While ((j < totalcount) And (myitems(j).Class <> olContact))
    Your counting all items that are NOT contacts? Shouldnt you be just getting the first and Last name from the selected email and execute a .Find or .Restrict on the respective contact itmes fields?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  34. #34

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    can you please rectify the code.
    i tried but am not able to do it.

    kindly help
    cheers
    visual basic.net (2008)

    .net framework 3.5


  35. #35

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    kindly help
    cheers
    visual basic.net (2008)

    .net framework 3.5


  36. #36

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    490

    Re: extracting email id ,name from outlook REMOVING DUPLICATE CONTACT ENTRIES

    VB Code:
    1. Public Sub deleteduplicatecontacts()
    2. Dim oldcontact As ContactItem, newcontact As ContactItem, j As Integer
    3. Dim mynamespace As Outlook.NameSpace
    4. Dim myitems As Items
    5. Dim myfolder As Outlook.MAPIFolder
    6. Dim i As Integer
    7. Dim totalcount As Integer
    8.  
    9. Set mynamespace = GetNamespace("MAPI")
    10.  
    11. Set myfolder = mynamespace.GetDefaultFolder(olFolderContacts)
    12. Set myitems = myfolder.Items
    13. myitems.Sort "[File As]", olDescending
    14. totalcount = myitems.Count
    15. j = 1
    16. While ((j < totalcount) And (myitems(j).Class <> olContact))
    17.   j = j + 1
    18. Wend
    19. Set oldcontact = myitems(j)
    20. 'For i = j + 1 To totalcount
    21. For i = totalcount To (j + 1) Step -1
    22.  
    23.   If (myitems(i).Class = olContact) Then
    24.     Set newcontact = myitems(i)
    25.     'if((newcontact.lastmodificationtime = oldcontact.lastmodificationtime) and
    26.     If ((newcontact.LastNameAndFirstName = oldcontact.LastNameAndFirstName) And _
    27.         (newcontact.FileAs = oldcontact.FileAs) And _
    28.         (newcontact.PagerNumber = oldcontact.PagerNumber) And _
    29.         (newcontact.HomeTelephoneNumber = oldcontact.HomeTelephoneNumber) And _
    30.         (newcontact.BusinessTelephoneNumber = oldcontact.BusinessTelephoneNumber) And _
    31.         (newcontact.BusinessAddress = oldcontact.BusinessAddress) And _
    32.         (newcontact.Email1Address = oldcontact.Email1Address) And _
    33.         (newcontact.HomeAddress = oldcontact.HomeAddress) And _
    34.         (newcontact.CompanyName = oldcontact.CompanyName)) Then
    35.       'use FTPSite as a flag to mark duplicates
    36.       newcontact.Delete  '= "DELETEMESEYMOUR" 'FTPSite
    37.       newcontact.Save
    38.     End If
    39.     Set oldcontact = newcontact
    40.  
    41.   End If
    42. Next i
    43. End Sub

    above is the latest code. but now i have error : array index out of bounds
    kindly help
    cheers
    visual basic.net (2008)

    .net framework 3.5


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width