![]() |
| 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. |
|
|||||||
| Tags: attachments, multiple, outlook, sending |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I have an ACCESS database that writes anywhere from 1 to 3 reports to a
static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
| Ads |
|
#2
|
|||
|
|||
|
Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.:
A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
|
#3
|
|||
|
|||
|
Michael,
Thank you for your response, I am not sure what I am doing wrong. This looks so simple but I am still not able to get it to work. Let me give you a little more detail about what's happening: I have an ACCESS application that writes files to a static directory like I mentioned before. Once the files are written, I open an e-mail with a purchase order as an attachment using the following command: DoCmd.SendObject acSendReport, "rptMaterialPurchaseOrders-Email", acFormatRTF, , , , "Omni Purchase Order", Chr(13) & Chr(13), , False At this point the e-mail is open. I now manually attach 1 to 3 product specifications before sending it to the supplier. From within the currently open e-mail, I want to have a button that will add the files from the directory. I have the code set up to read the names of the files in the directory and can list them one by one. I just need to figure out how to attach them. When I run the code you sent me, I get the following error: Compile Error: User-Defined Type Not Defined and it is refering to the line: Mail As Outlook.MailItem Any Ideas? Thank You again. "Michael Bauer [MVP - Outlook]" wrote: Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.: A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
|
#4
|
|||
|
|||
|
Am Fri, 4 Aug 2006 09:17:02 -0700 schrieb Bob B.:
Yes, if the code runs within Access you need to add a ref to Outlook via Tools/References. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, Thank you for your response, I am not sure what I am doing wrong. This looks so simple but I am still not able to get it to work. Let me give you a little more detail about what's happening: I have an ACCESS application that writes files to a static directory like I mentioned before. Once the files are written, I open an e-mail with a purchase order as an attachment using the following command: DoCmd.SendObject acSendReport, "rptMaterialPurchaseOrders-Email", acFormatRTF, , , , "Omni Purchase Order", Chr(13) & Chr(13), , False At this point the e-mail is open. I now manually attach 1 to 3 product specifications before sending it to the supplier. From within the currently open e-mail, I want to have a button that will add the files from the directory. I have the code set up to read the names of the files in the directory and can list them one by one. I just need to figure out how to attach them. When I run the code you sent me, I get the following error: Compile Error: User-Defined Type Not Defined and it is refering to the line: Mail As Outlook.MailItem Any Ideas? Thank You again. "Michael Bauer [MVP - Outlook]" wrote: Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.: A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
|
#5
|
|||
|
|||
|
Michael,
I don't actually want to runt this code from ACCESS, I want to run it from the OutLook note that the attachments are to be entered into. "Michael Bauer [MVP - Outlook]" wrote: Am Fri, 4 Aug 2006 09:17:02 -0700 schrieb Bob B.: Yes, if the code runs within Access you need to add a ref to Outlook via Tools/References. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, Thank you for your response, I am not sure what I am doing wrong. This looks so simple but I am still not able to get it to work. Let me give you a little more detail about what's happening: I have an ACCESS application that writes files to a static directory like I mentioned before. Once the files are written, I open an e-mail with a purchase order as an attachment using the following command: DoCmd.SendObject acSendReport, "rptMaterialPurchaseOrders-Email", acFormatRTF, , , , "Omni Purchase Order", Chr(13) & Chr(13), , False At this point the e-mail is open. I now manually attach 1 to 3 product specifications before sending it to the supplier. From within the currently open e-mail, I want to have a button that will add the files from the directory. I have the code set up to read the names of the files in the directory and can list them one by one. I just need to figure out how to attach them. When I run the code you sent me, I get the following error: Compile Error: User-Defined Type Not Defined and it is refering to the line: Mail As Outlook.MailItem Any Ideas? Thank You again. "Michael Bauer [MVP - Outlook]" wrote: Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.: A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
|
#6
|
|||
|
|||
|
Am Fri, 4 Aug 2006 09:43:01 -0700 schrieb Bob B.:
Ok, let“s start again, forget all of my sample, but the line Mail.Attachments.Add: It shows you how to add one attachment to a given e-mail. If you do have the code already to read all the file names then call that line for each file. To the opened MailItem you could refer with: Dim Mail as Outlook.MailItem Set Mail=Application.ActiveInspector.CurrentItem If you write that code into Outlook then for sure you won“t get the error you mentioned (else you didn“t copy it and have a typo). -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, I don't actually want to runt this code from ACCESS, I want to run it from the OutLook note that the attachments are to be entered into. "Michael Bauer [MVP - Outlook]" wrote: Am Fri, 4 Aug 2006 09:17:02 -0700 schrieb Bob B.: Yes, if the code runs within Access you need to add a ref to Outlook via Tools/References. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, Thank you for your response, I am not sure what I am doing wrong. This looks so simple but I am still not able to get it to work. Let me give you a little more detail about what's happening: I have an ACCESS application that writes files to a static directory like I mentioned before. Once the files are written, I open an e-mail with a purchase order as an attachment using the following command: DoCmd.SendObject acSendReport, "rptMaterialPurchaseOrders-Email", acFormatRTF, , , , "Omni Purchase Order", Chr(13) & Chr(13), , False At this point the e-mail is open. I now manually attach 1 to 3 product specifications before sending it to the supplier. From within the currently open e-mail, I want to have a button that will add the files from the directory. I have the code set up to read the names of the files in the directory and can list them one by one. I just need to figure out how to attach them. When I run the code you sent me, I get the following error: Compile Error: User-Defined Type Not Defined and it is refering to the line: Mail As Outlook.MailItem Any Ideas? Thank You again. "Michael Bauer [MVP - Outlook]" wrote: Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.: A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
|
#7
|
|||
|
|||
|
Michael,
Thank You for all of your help, I believe the problem I am having is due to the proper reference not being set. I noticed I had the Microsoft Office 11.0 Object Library but not the Microsoft Outlook 11.0 Object Library. Selecting it fixed some of the problem but not all of them. I still do not recognize the ActiveInspector part of the Set Mail = Application command. I wll see if I can locate the proper reference. Once again, I appreciate your help and apologize for my ignorance. "Michael Bauer [MVP - Outlook]" wrote: Am Fri, 4 Aug 2006 09:43:01 -0700 schrieb Bob B.: Ok, let“s start again, forget all of my sample, but the line Mail.Attachments.Add: It shows you how to add one attachment to a given e-mail. If you do have the code already to read all the file names then call that line for each file. To the opened MailItem you could refer with: Dim Mail as Outlook.MailItem Set Mail=Application.ActiveInspector.CurrentItem If you write that code into Outlook then for sure you won“t get the error you mentioned (else you didn“t copy it and have a typo). -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, I don't actually want to runt this code from ACCESS, I want to run it from the OutLook note that the attachments are to be entered into. "Michael Bauer [MVP - Outlook]" wrote: Am Fri, 4 Aug 2006 09:17:02 -0700 schrieb Bob B.: Yes, if the code runs within Access you need to add a ref to Outlook via Tools/References. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, Thank you for your response, I am not sure what I am doing wrong. This looks so simple but I am still not able to get it to work. Let me give you a little more detail about what's happening: I have an ACCESS application that writes files to a static directory like I mentioned before. Once the files are written, I open an e-mail with a purchase order as an attachment using the following command: DoCmd.SendObject acSendReport, "rptMaterialPurchaseOrders-Email", acFormatRTF, , , , "Omni Purchase Order", Chr(13) & Chr(13), , False At this point the e-mail is open. I now manually attach 1 to 3 product specifications before sending it to the supplier. From within the currently open e-mail, I want to have a button that will add the files from the directory. I have the code set up to read the names of the files in the directory and can list them one by one. I just need to figure out how to attach them. When I run the code you sent me, I get the following error: Compile Error: User-Defined Type Not Defined and it is refering to the line: Mail As Outlook.MailItem Any Ideas? Thank You again. "Michael Bauer [MVP - Outlook]" wrote: Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.: A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
|
#8
|
|||
|
|||
|
To anyone who may want to do a similar thing as I was trying to do, I found a
code sample at: http://www.vba-programmer.com/Snippe..._to_Email.html that with a little modicication will do exactly what I want. I have tried it and it works perfectly for my application. Once again, I would like to thank Michael for all of his patience and assistance. Your examples kept me searching and working towards a solution and allowed me to stumble onto this fix. Thank You. "Bob B." wrote: Michael, Thank You for all of your help, I believe the problem I am having is due to the proper reference not being set. I noticed I had the Microsoft Office 11.0 Object Library but not the Microsoft Outlook 11.0 Object Library. Selecting it fixed some of the problem but not all of them. I still do not recognize the ActiveInspector part of the Set Mail = Application command. I wll see if I can locate the proper reference. Once again, I appreciate your help and apologize for my ignorance. "Michael Bauer [MVP - Outlook]" wrote: Am Fri, 4 Aug 2006 09:43:01 -0700 schrieb Bob B.: Ok, let“s start again, forget all of my sample, but the line Mail.Attachments.Add: It shows you how to add one attachment to a given e-mail. If you do have the code already to read all the file names then call that line for each file. To the opened MailItem you could refer with: Dim Mail as Outlook.MailItem Set Mail=Application.ActiveInspector.CurrentItem If you write that code into Outlook then for sure you won“t get the error you mentioned (else you didn“t copy it and have a typo). -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, I don't actually want to runt this code from ACCESS, I want to run it from the OutLook note that the attachments are to be entered into. "Michael Bauer [MVP - Outlook]" wrote: Am Fri, 4 Aug 2006 09:17:02 -0700 schrieb Bob B.: Yes, if the code runs within Access you need to add a ref to Outlook via Tools/References. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- Michael, Thank you for your response, I am not sure what I am doing wrong. This looks so simple but I am still not able to get it to work. Let me give you a little more detail about what's happening: I have an ACCESS application that writes files to a static directory like I mentioned before. Once the files are written, I open an e-mail with a purchase order as an attachment using the following command: DoCmd.SendObject acSendReport, "rptMaterialPurchaseOrders-Email", acFormatRTF, , , , "Omni Purchase Order", Chr(13) & Chr(13), , False At this point the e-mail is open. I now manually attach 1 to 3 product specifications before sending it to the supplier. From within the currently open e-mail, I want to have a button that will add the files from the directory. I have the code set up to read the names of the files in the directory and can list them one by one. I just need to figure out how to attach them. When I run the code you sent me, I get the following error: Compile Error: User-Defined Type Not Defined and it is refering to the line: Mail As Outlook.MailItem Any Ideas? Thank You again. "Michael Bauer [MVP - Outlook]" wrote: Am Thu, 3 Aug 2006 13:40:02 -0700 schrieb Bob B.: A NoteItem can“t have attachments. Do you mean a MailItem? Maybe you can extend the code that writes the files, at that point you do know the file names and how many there“re. Dim Mail as Outlook.MailItem Set Mail=Application.CreateItem(olMailItem) ' Here the loop that probably write the files for i=1 to 3 ' write the file ' attach it Mail.Attachments.Add filename next -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook -- www.VBOffice.net -- I have an ACCESS database that writes anywhere from 1 to 3 reports to a static directory (C:\Mfg_Software\EMails\FileName.pdf). The directory is emptied by the code prior to writing the pdf's so the only files in it are the ones I want to send. What I would like to do is press a button and have it attach all files from that directory to my note. I found the following example from Eric Legault from 8/23/2005 that looked like it would work but I can't get it to. Sub AddAttachments() Dim objItem As Object If ActiveExplorer.Selection.Count = 0 Then Exit Sub For Each objItem In ActiveExplorer.Selecion objItem.Attachments.Add ("C:\Mfg_Software\EMails\147.pdf") objItem.Save Next End Sub I am using a static file name in this example but can handle the multiple names through code if I can just get the Attachment to work. Can anyone out there give me some insight as to what I am doing wrong? I have Outlook 2003 and tried using this as a macro from the Main Outlook screen as well as from inside a new note. Thank You in advance for any help you can give me. Regards, Bob |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Outlook Express sending 'extra' attachments... | Nick | Outlook Express | 1 | April 25th 06 09:16 PM |
| Problem sending attachments | Newguyhere | Outlook Express | 5 | April 11th 06 05:05 AM |
| Problems sending attachments in Outlook 2003, but works through VNC | Gavin Hanover | Outlook - General Queries | 0 | January 26th 06 06:14 PM |
| Outlook deadly slow (mostly static!) when sending attachments | Spamfree! | Outlook - General Queries | 2 | January 24th 06 05:04 PM |
| attachments disappear when sending from Act! through Outlook | doug2000 | Outlook - Installation | 0 | January 11th 06 01:05 AM |