![]() |
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
|
|||
|
|||
![]()
TIA:
I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is I tried the code on my computer at home and it works fine. Any ideas as to the problem/solution are much appreciated. Joel |
Ads |
#2
|
|||
|
|||
![]()
To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is I tried the code on my computer at home and it works fine. Any ideas as to the problem/solution are much appreciated. Joel |
#3
|
|||
|
|||
![]()
Thanks Sue...
But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is I tried the code on my computer at home and it works fine. Any ideas as to the problem/solution are much appreciated. Joel |
#4
|
|||
|
|||
![]()
What specifically doesn't work? Have you stepped through the code in the debugger? Didn't you want to process all the items in the Outbox, not just one?
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... Thanks Sue... But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is |
#5
|
|||
|
|||
![]()
Sorry for being unclear:
I am trying to cycle through All items in the outbox. In stepping through code, the first email gets an attachment then when it cycles to the second email (I see the address as the variable) but then, error, "item has been moved or deleted" when it goes to the attach command. You're so kind for the help. Joel "Sue Mosher [MVP-Outlook]" wrote: What specifically doesn't work? Have you stepped through the code in the debugger? Didn't you want to process all the items in the Outbox, not just one? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... Thanks Sue... But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is |
#6
|
|||
|
|||
![]()
Hello Sue:
To be clear I have emails in the outbox with one email address. I need to be able to attach a specific file depending on the address. I need to be able to cycle through each email and test the addess (hence the if..elseif..endif) to see which file to attach and send. My original code cycled through all of the emails just fine but I obvioiusly am having trouble to write the code to cycle through each email and look at the item.address. Your help is appreciated, Joel "Sue Mosher [MVP-Outlook]" wrote: What specifically doesn't work? Have you stepped through the code in the debugger? Didn't you want to process all the items in the Outbox, not just one? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... Thanks Sue... But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is |
#7
|
|||
|
|||
![]()
If you had a good routine to cycle through the items, why aren't you using it in this latest version, adding to it your Recipients checking routine?
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... Hello Sue: To be clear I have emails in the outbox with one email address. I need to be able to attach a specific file depending on the address. I need to be able to cycle through each email and test the addess (hence the if..elseif..endif) to see which file to attach and send. My original code cycled through all of the emails just fine but I obvioiusly am having trouble to write the code to cycle through each email and look at the item.address. Your help is appreciated, Joel "Sue Mosher [MVP-Outlook]" wrote: What specifically doesn't work? Have you stepped through the code in the debugger? Didn't you want to process all the items in the Outbox, not just one? "Joel" wrote in message ... Thanks Sue... But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is |
#8
|
|||
|
|||
![]()
I understand some concepts here but not sure of the details...It seems there
need to be a loop through recipients and items...here's what I have that isn't right... Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items For Each objItem In Items If objItem.Recipients = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf objItem.Recipients = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send ElseIf objItem.Recipients = " Then objItem.Attachments.Add ("C:\copper\118.xls") objItem.Send End If Next End Sub I'm not sure what to do within the For each item in items loop to get to the recipient.address Help?? Thanks, Joel "Sue Mosher [MVP-Outlook]" wrote: If you had a good routine to cycle through the items, why aren't you using it in this latest version, adding to it your Recipients checking routine? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... Hello Sue: To be clear I have emails in the outbox with one email address. I need to be able to attach a specific file depending on the address. I need to be able to cycle through each email and test the addess (hence the if..elseif..endif) to see which file to attach and send. My original code cycled through all of the emails just fine but I obvioiusly am having trouble to write the code to cycle through each email and look at the item.address. Your help is appreciated, Joel "Sue Mosher [MVP-Outlook]" wrote: What specifically doesn't work? Have you stepped through the code in the debugger? Didn't you want to process all the items in the Outbox, not just one? "Joel" wrote in message ... Thanks Sue... But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is |
#9
|
|||
|
|||
![]()
I think I got it Sue, what do you think???
Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items For Each objItem In Items Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\118.xls") objItem.Send End If Next Next End Sub Thanks, Joel "Sue Mosher [MVP-Outlook]" wrote: If you had a good routine to cycle through the items, why aren't you using it in this latest version, adding to it your Recipients checking routine? -- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... Hello Sue: To be clear I have emails in the outbox with one email address. I need to be able to attach a specific file depending on the address. I need to be able to cycle through each email and test the addess (hence the if..elseif..endif) to see which file to attach and send. My original code cycled through all of the emails just fine but I obvioiusly am having trouble to write the code to cycle through each email and look at the item.address. Your help is appreciated, Joel "Sue Mosher [MVP-Outlook]" wrote: What specifically doesn't work? Have you stepped through the code in the debugger? Didn't you want to process all the items in the Outbox, not just one? "Joel" wrote in message ... Thanks Sue... But I'm stuck..here's what I have close but doesn't work..any more help?? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items Set objItem = Items.Item(1) Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send End If Next End Sub I really appreciate your help Joel "Sue Mosher [MVP-Outlook]" wrote: To returns only display names/addresses. You should instead iterate the objItem.Recipients collection and check each Recipient.Address and Recipient.Type. "Joel" wrote in message ... TIA: I have the following code to attach a file to email. Sub Add_Attachment_To_Messages() Dim oFolder As Outlook.MAPIFolder Dim items As Outlook.items Dim objItem As MailItem Set items = Application.GetNamespace("MAPI").GetDefaultFolder _(olFolderOutbox).items For Each objItem In items If objItem.To = '" Then objItem.Attachments.Add ("\\copper\115.xls") objItem.Send End If Next End Sub The email is opened but no attachement. In the code I have tried the actual email address and the Display As address and neither work??? Outlook is in a network with Exchange Server that Creates Dispay As info such as Bob Smith (ND) where the email is |
#10
|
|||
|
|||
![]()
Why not try it and see for yourself? If it modifies only half the items, we can switch from the For Each loop to a countdown loop.
-- Sue Mosher, Outlook MVP Author of Configuring Microsoft Outlook 2003 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Joel" wrote in message ... I think I got it Sue, what do you think??? Sub Send_Attachment_Messages() Dim oFolder As Outlook.MAPIFolder Dim Items As Outlook.Items Dim objItem As MailItem Dim Recips As Recipients Dim Recip As Recipient Set Items = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderOutbox).Items For Each objItem In Items Set Recips = objItem.Recipients For Each Recip In Recips If Recip.Address = " Then objItem.Attachments.Add ("C:\copper\115.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\116.xls") objItem.Send ElseIf Recip.Address = " Then objItem.Attachments.Add ("C:\copper\118.xls") objItem.Send End If Next Next End Sub |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
If the control has a field assigned, the code "_click()" doesn't w | Arturo | Outlook - Using Forms | 1 | October 18th 06 02:24 PM |
How to set holidays as "Out of office" in "Show time as" field? | TFS | Outlook - Calandaring | 0 | May 22nd 06 04:40 PM |
DO NOT include field "Title" in the name column in "To" search | Rob G. | Outlook - Using Contacts | 7 | May 3rd 06 09:47 PM |
Removing unwanted "Auto Complete" addresses from the "To:" field? | Pilgrim | Outlook - General Queries | 1 | May 1st 06 08:15 PM |
"Percent" field changed to "Number" field | Vaughan | Outlook - Using Forms | 1 | March 14th 06 02:32 PM |