Re: Outlook Automation Problem
- From: "Alastair MacFarlane" <anonymous@xxxxxxxxxxxxx>
- Date: Sun, 23 Oct 2005 19:20:34 +0100
Norm
Why not use a Distribution List and then send to all members of the
distribution list and then you won't need to loop through all the members
individually. I have used this method before. I have attached a rather crude
sub and ignore some of the code as I have not had a chance to edit it for
this post:
Alastair
Public Sub ShowDistNames()
Dim bolFound As Boolean
Dim objNS As Outlook.NameSpace
Dim objContact As DistListItem
Dim objItems As Outlook.Items
Dim objContactsFolder As Outlook.MAPIFolder
Dim objRecipient As Outlook.Recipient
Dim obj As Object
Dim i As Integer
bolFound = False
Set objNS = objOA.GetNamespace("MAPI")
Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)
Set objItems = objContactsFolder.Items
For Each obj In objItems
If obj.Class = olDistributionList Then
Set objContact = obj
If objContact.Subject = "NonAttendanceList" Then
With objContact
For i = 1 To objContact.MemberCount
Set objRecipient = .GetMember(i)
With objRecipient
mvarListBox.AddItem .Name & "; ... " & .Address
End With
Next
bolFound = True
End With
End If
End If
Err.Clear
Next
Set objNS = Nothing
Set obj = Nothing
Set objContact = Nothing
Set objItems = Nothing
Set objContactsFolder = Nothing
If bolFound = False Then
nonAtt.ShowAction ("The distribution list SportNonAttendanceList is
not found. " & vbCrLf & _
"It looks like it has been deleted, renamed or moved.")
Else
nonAtt.ShowAction ("The distribution list SportNonAttendanceList was
found. " & vbCrLf & _
"and opened successfully.")
End If
End Sub
"Norm" <nofo@xxxxxxxxxxx> wrote in message
news:9aQ6f.13699$MN6.807@xxxxxxxxxxxxx
> Veign, Alastair,
>
> Thanks for the answer and I guess my question was not really clear or
> maybe I am doing the emailing wrong to begin with.
>
> The error is not coming when I loop through the contacts and add each one
> to a list called AllUsers. When all the contacts have been added AllUsers
> is used as the Recipient for Outlook email. When the Send command is given
> the error occurs, but the user has no idea which name has not been
> recognized out of the group.
>
> I was just looking for a way to check the names as the program looped
> through them to add them to the AllUsers group and I would trap the error
> here, giving the name to the user, but still letting Outlook send to the
> rest of the group. The way it is now when Outlook generates the error it
> does not send the email to anyone until the bad name is corrected.
>
> If there is not a way of doing this I could have the program send
> individual emails, but I would like to avoid this if possible.
>
> Not having access to a network or exchange server makes it a little
> difficult for me to experiment with different options.
>
> Norm
> "Alastair MacFarlane" <anonymous@xxxxxxxxxxxxx> wrote in message
> news:emBfbm$1FHA.460@xxxxxxxxxxxxxxxxxxxxxxx
>> Norm,
>>
>> I am sorry but I don't have a solution but merely a sense of direction if
>> you don't get a plausible answer. I would look down the Collaboration
>> Data Objects route wich will be able to query the exchange server for
>> information that cannot be obtained directly through the Outlook object
>> model.
>>
>> I am slightly confused as to why a loop through the recipients brings up
>> errors. Could you have different groups set up on the exchange server and
>> you are only looping through a subset of the whole. Our exchange server
>> is grouped by department and you have to select the department to loop
>> through the members.
>>
>> Anyway I would suggest CDO as your most likely way forward.
>>
>> I hope this helps in a small way.
>>
>> Alastair MacFarlane
>>
>> "Norm" <nofo@xxxxxxxxxxx> wrote in message
>> news:mJP6f.13696$MN6.9928@xxxxxxxxxxxxx
>>> Hi,
>>>
>>> I had asked this question in the Outlook group, but did not get an
>>> answer. Hopefully someone here can help me.
>>>
>>> I have an application being used in another state that emails a form to
>>> a
>>> list of people in the users contact list. They are using Outlook and
>>> occasionally get an error message that one or more users is not
>>> recognized
>>> by Outlook.
>>>
>>> The program loops through the list adding each name to the recipient
>>> list
>>> and I was wondering if there was a way to check each name against the
>>> server
>>> at this point to see if it is valid. I do not have access to a network
>>> with
>>> an exchange server to test this on and any help would be appreciated.
>>>
>>> Thanks,
>>> Norm
>>>
>>>
>>>
>>
>>
>
>
.
- Follow-Ups:
- Re: Outlook Automation Problem
- From: Norm
- Re: Outlook Automation Problem
- References:
- Outlook Automation Problem
- From: Norm
- Re: Outlook Automation Problem
- From: Alastair MacFarlane
- Outlook Automation Problem
- Prev by Date: Re: Outlook Automation Problem
- Next by Date: Re: How to change the value of Boolean variable?
- Previous by thread: Re: Outlook Automation Problem
- Next by thread: Re: Outlook Automation Problem
- Index(es):
Relevant Pages
|
Loading