![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |