?
Solved

Outlook Command

Posted on 2013-12-27
2
Medium Priority
?
292 Views
Last Modified: 2013-12-31
Was looking for some code to add a Receipent to the Contacts List, and changing it up a bit to have some code that would add the Sender to the Contacts List with a category color attached to it.   However, in "blowing off" some old code, this one seemed to fit the Receiptent portion of what was needed, but it keeps erroring out on: "AddQuote."

Sub AddRecipToContacts()
    Dim strFind As String
    Dim strAddress As String
    Dim objNS As Outlook.NameSpace
    Dim colContacts As Outlook.Items
    Dim objContact As Outlook.ContactItem
    Dim objRecip As Outlook.Recipient
    Dim objMail As Outlook.MailItem
    Dim i As Integer
    On Error Resume Next

    If TypeName(Application.ActiveWindow) = "Explorer" Then
        Set objMail = Application.ActiveExplorer.Selection(1)
    ElseIf TypeName(Application.ActiveWindow) = "Inspector" Then
        Set objMail = Application.ActiveInspector.CurrentItem
    Else
        Exit Sub
    End If
    ' get Contacts folder and its Items collection
    Set objNS = Application.GetNamespace("MAPI")
    Set colContacts = _
      objNS.GetDefaultFolder(olFolderContacts).Items

    ' process message recipients
    For Each objRecip In objMail.Recipients
        ' check to see if the recip is already in Contacts
'-----------------------------------------
        strAddress = AddQuote(objRecip.Address)
 '-----------------------------------------     

         For i = 1 To 3
            strFind = "[Email" & i & "Address] = " & _
                      strAddress
            Set objContact = colContacts.Find(strFind)
            If Not objContact Is Nothing Then
                Exit For
            End If
       Next

Open in new window

Does AddQuote belong to an object in the Reference Library, which is not loaded, or is this code for a 2007 version and AddQuote is no longer part of object model?  If not what would take it's place?
0
Comment
Question by:Cook09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 2000 total points
ID: 39743190
Addquote is an oft used USER DEFINED function to simply add a quote keeping the text block tidyas such the original code may have used a different form but I would expect something like:

Function addQuote(str As String)
    addQuote = Chr(34) & str & Chr(34)
End Function

Open in new window

add this to the end of your code and hopefully!

Chris
0
 

Author Comment

by:Cook09
ID: 39749112
Hi Chris,

Yes, that is what it referred to in this situation.   However, what it provides I can't use, so I had to change the objects around to display what I needed.  But, this cleared the bottleneck.

Thanks...Cook
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

762 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