A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Issue with Resolving Names



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 17th 07, 02:43 PM posted to microsoft.public.outlook.program_vba
AP[_2_]
external usenet poster
 
Posts: 2
Default Issue with Resolving Names

Hello
I am building a program that creates documents in excel and sends them
to the draft folder in outlook. Once everything is in the draft
folder, the user can either review each document or use the following
code to 'send all' Now the problem I am having is that the names
cannot resolve. So even though if I open each email individually and
wait a few seconds, the email address will reappear with an underline
and I can send it manually, I keep getting the outlook does not
recognize names error. Could anyone please give me guidance. This
program is sending to an email address that is a fax server. Here is
the code.
Thanks in advance.

Public Sub SendDrafts()

Dim lDraftItem As Long
Dim myOutlook As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim myDraftsFolder As Outlook.MAPIFolder
'Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookRecip As Object
Dim strTo As String
'Send all items in the "Drafts" folder that have a "To" address filled
'in.

'Setup Outlook Dim oFolder As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim oMail As Outlook.MailItem


Set myOutlook = Outlook.Application
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders

'Set Draft Folder.

Set myDraftsFolder =
Application.GetNamespace("MAPI").GetDefaultFolder( olFolderDrafts)

'Loop through all Draft Items

For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1

If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To) ) 0 Then
If Left(Trim(myDraftsFolder.Items.Item(lDraftItem).To ), 5) =
"[RFax" Then
'Send Item
strTo = myDraftsFolder.Items.Item(lDraftItem).To

With myDraftsFolder.Items.Item(lDraftItem)
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = olTo

'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

End With



myDraftsFolder.Items.Item(lDraftItem).Send
End If
End If
Next lDraftItem

'Clean-up

Set myDraftsFolder = Nothing
Set myNameSpace = Nothing
Set myOutlook = Nothing

End Sub


  #2  
Old December 17th 07, 04:50 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Issue with Resolving Names

program is sending to an email address that is a fax server.

Please clarify what you mean by that by providing a typical value strTo.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"AP" wrote in message ...
Hello
I am building a program that creates documents in excel and sends them
to the draft folder in outlook. Once everything is in the draft
folder, the user can either review each document or use the following
code to 'send all' Now the problem I am having is that the names
cannot resolve. So even though if I open each email individually and
wait a few seconds, the email address will reappear with an underline
and I can send it manually, I keep getting the outlook does not
recognize names error. Could anyone please give me guidance. This
program is sending to an email address that is a fax server. Here is
the code.
Thanks in advance.

Public Sub SendDrafts()

Dim lDraftItem As Long
Dim myOutlook As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim myDraftsFolder As Outlook.MAPIFolder
'Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookRecip As Object
Dim strTo As String
'Send all items in the "Drafts" folder that have a "To" address filled
'in.

'Setup Outlook Dim oFolder As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim oMail As Outlook.MailItem


Set myOutlook = Outlook.Application
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders

'Set Draft Folder.

Set myDraftsFolder =
Application.GetNamespace("MAPI").GetDefaultFolder( olFolderDrafts)

'Loop through all Draft Items

For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1

If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To) ) 0 Then
If Left(Trim(myDraftsFolder.Items.Item(lDraftItem).To ), 5) =
"[RFax" Then
'Send Item
strTo = myDraftsFolder.Items.Item(lDraftItem).To

With myDraftsFolder.Items.Item(lDraftItem)
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = olTo

'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

End With



myDraftsFolder.Items.Item(lDraftItem).Send
End If
End If
Next lDraftItem

'Clean-up

Set myDraftsFolder = Nothing
Set myNameSpace = Nothing
Set myOutlook = Nothing

End Sub


  #3  
Old December 18th 07, 09:54 PM posted to microsoft.public.outlook.program_vba
AP[_2_]
external usenet poster
 
Posts: 2
Default Issue with Resolving Names

On Dec 17, 10:50 am, "Sue Mosher [MVP-Outlook]"
wrote:
program is sending to an email address that is a fax server.


Please clarify what you mean by that by providing a typical value strTo.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54



"AP" wrote in ...
Hello
I am building a program that creates documents in excel and sends them
to the draft folder in outlook. Once everything is in the draft
folder, the user can either review each document or use the following
code to 'send all' Now the problem I am having is that the names
cannot resolve. So even though if I open each email individually and
wait a few seconds, the email address will reappear with an underline
and I can send it manually, I keep getting the outlook does not
recognize names error. Could anyone please give me guidance. This
program is sending to an email address that is a fax server. Here is
the code.
Thanks in advance.


Public Sub SendDrafts()


Dim lDraftItem As Long
Dim myOutlook As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolders As Outlook.Folders
Dim myDraftsFolder As Outlook.MAPIFolder
'Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookRecip As Object
Dim strTo As String
'Send all items in the "Drafts" folder that have a "To" address filled
'in.


'Setup Outlook Dim oFolder As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim oMail As Outlook.MailItem


Set myOutlook = Outlook.Application
Set myNameSpace = myOutlook.GetNamespace("MAPI")
Set myFolders = myNameSpace.Folders


'Set Draft Folder.


Set myDraftsFolder =
Application.GetNamespace("MAPI").GetDefaultFolder( olFolderDrafts)


'Loop through all Draft Items


For lDraftItem = myDraftsFolder.Items.Count To 1 Step -1


If Len(Trim(myDraftsFolder.Items.Item(lDraftItem).To) ) 0 Then
If Left(Trim(myDraftsFolder.Items.Item(lDraftItem).To ), 5) =
"[RFax" Then
'Send Item
strTo = myDraftsFolder.Items.Item(lDraftItem).To


With myDraftsFolder.Items.Item(lDraftItem)
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strTo)
objOutlookRecip.Type = olTo


'Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next


End With


myDraftsFolder.Items.Item(lDraftItem).Send
End If
End If
Next lDraftItem


'Clean-up


Set myDraftsFolder = Nothing
Set myNameSpace = Nothing
Set myOutlook = Nothing


End Sub- Hide quoted text -


- Show quoted text -


Hello.
Thank you for your response. I figured it out. The code was fine, the
problem was a comma in the address that cause it to think there were
multiple recipients. I replaced the comma with a space because it was
not needed to begin with. Thanks.
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue resolve DNS names POP3 and SMTP Federico Outlook - Installation 0 October 24th 07 06:54 PM
resolving distlist Michael[_3_] Add-ins for Outlook 1 September 5th 07 09:36 PM
dual names issue Dean Outlook - General Queries 2 May 10th 07 05:26 PM
How to stop fax number showing as address when resolving names Bob Harley Outlook - Using Contacts 1 November 22nd 06 06:08 PM
Re-resolving servers CDGEN Outlook - Installation 0 January 12th 06 02:59 PM


All times are GMT +1. The time now is 07:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.