+ Reply to Thread
Results 1 to 18 of 18

Outlook MailItem Object Adding Attachments Issue

  1. #1
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Outlook MailItem Object Adding Attachments Issue

    Hi,
    I am creating a macro that creates a draft of an email in Outlook and pulls an attachment from a specific path. My code has been working, up until the point of adding attachments. The To, From, Cc, Bcc, subject, body, etc. all work but when adding in Attachments.Add I get the error message "Object required." If I simply use ".Add" I get the error message "Object doesn't support this property or method." Below is the snippet of code where the ".Attachments.Add" and ".Add" are failing. Any advice is highly appreciated :D

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Outlook MailItem Object Adding Attachments Issue

    Hi there Edward,

    If you put Debug.Print File_Source & "\" & Invoice_Num & ".pdf" just before .Add File_Source & "\" & Invoice_Num & ".pdf" what do you get in the Immediate window?
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  3. #3
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    Update:

    The following code worked, however, the file isn't being attached. The name of the file is "123," not "123.pdf," so I removed the ".pdf" portion, and I've tried having the cell value for the Invoice_Num variable be both text and number formats. Invoice_Num is dimmed as a variant. Any help on this portion is highly appreciated.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Outlook MailItem Object Adding Attachments Issue

    It should be .Attachments.Add
    Rory

  5. #5
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    Sorry, I didn't refresh the page before submitting my reply. There is no error message after my code update, it just isn't adding the attachment.

  6. #6
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Outlook MailItem Object Adding Attachments Issue

    try .Attachments.Add not just .attachments

  7. #7
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    I tried this and it is saying "Cannot find this file. Verify the path and file name are correct." I don't know why it is doing this. I added in the msgbox method to show what it is searching for specifically and it shows the correct file path and file name. I double checked the properties of the file in windows explorer and the path is the same. The file name is also correct. Any ideas?

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Outlook MailItem Object Adding Attachments Issue

    Are you sure the file doesn't have an extension? That's pretty unusual.

  9. #9
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    I tried it with ".pdf" and without and it is saved as a pdf.

  10. #10
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Outlook MailItem Object Adding Attachments Issue

    If you browse, using the windows explorer, to the location of the file (exactly as in File_Source) can you see the file there? Is your windows system set up to show the file extensions?

  11. #11
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    I tried the browsing instructions you gave and it does bring me there.

    I don't know exactly. I will say, when looking in that path, it just shows "123" as the pdf name. Is that what you mean?

  12. #12
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Outlook MailItem Object Adding Attachments Issue

    Here: https://www.howtogeek.com/205086/beg...le-extensions/
    This will allow you to set up windows to see file extensions, so you will be able to see the entire file name and path and compare it with the one in the code.

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Outlook MailItem Object Adding Attachments Issue

    How do you get to the attachment being created ?

    Share the code where you create the pdf-file. If you use ExportAsFixedFormat the extension is added automatically.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  14. #14
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    I don't have code to create the PDF. Currently, the accounting department is manually creating the PDFs via word and saving them in that pathway. Am I understanding what you are asking correctly?

  15. #15
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    I will read over that link to see the path shortly. Thank you for that :D

  16. #16
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Outlook MailItem Object Adding Attachments Issue

    If you're using .Attachments.Add and the full file path with extension, and still getting a file not found error, then something has to be wrong with the path/name.

  17. #17
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Outlook MailItem Object Adding Attachments Issue

    How have you set File_Source ??

  18. #18
    Forum Contributor
    Join Date
    05-17-2017
    Location
    Tallahassee
    MS-Off Ver
    15.32
    Posts
    206

    Re: Outlook MailItem Object Adding Attachments Issue

    rorya, thank you! I realized that after converting text to columns, the leading zero in the actual invoice number was removed and not matching (I used an imaginary invoice number in this thread as an example). Thank you!!!!

    nigelog, I did set File_Source :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Object variable error when adding receipts to MS Outlook
    By Pi* in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-29-2017, 12:26 AM
  2. Help On My Outlook Attachments
    By Don Adeks in forum Outlook Formatting & Functions
    Replies: 3
    Last Post: 06-09-2015, 04:14 AM
  3. [SOLVED] Import MailItem properties from Outlook shared folder(s) to Excel
    By kaptenstofil in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2014, 05:26 AM
  4. Adding attachments adds to an open outlook item and sends only blank email
    By Prabhucpk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2014, 04:13 PM
  5. User form to add attachments and send the form and attachments via outlook
    By scorchio83 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2013, 03:46 AM
  6. Sending Outlook Attachments with VBA
    By nms2130 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2011, 12:36 PM
  7. adding multiple attachments to a macro in excel for a email using outlook
    By ccbltdneedhelp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2009, 11:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1