+ Reply to Thread
Results 1 to 14 of 14

MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

  1. #1
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Question MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Hello everyone,

    Just trying to send an email (gmail) using VBA CDO in excel and my problem is in the title.

    I'm pretty sure that everyone gets it. I want my mail attachment to be selected in a specific cell (that is doing a Vlookup on a customer name) in one of my sheets:

    Please Login or Register  to view this content.
    Here is the code:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 11-04-2014 at 11:40 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    anybody can help?

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Hello VBAzr,

    Have you verified that the contents of Sheets("MAIL").Range("N17").Text is a fully qualified file path like "C:\Users\Owner\My file.txt" ?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Hello!

    Yes I have! And if I put directly the path inside the code it works... of course...

    MAIL.AddAttachment "C:\Users\Owner\My file.txt"

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Hello VBAzr,

    Do receive any error messages?

  6. #6
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Leith,

    it just sends a No Name file...

    so two files are attached in the mail (the JPG I create inside the sheet + the not-working NO NAME attachement)

  7. #7
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Leith,

    Sorry, there is definitly an error message.

    Run-Time error'-2147024894 (80070002)':
    the specified file is not found

  8. #8
    Forum Contributor
    Join Date
    06-04-2013
    Location
    Moscow
    MS-Off Ver
    Office 365
    Posts
    100

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Add check:
    Please Login or Register  to view this content.
    And try use: Sheets("MAIL").Range("N17").Value
    I'm sorry my english...

  9. #9
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Maybe it is because my file is on a server and not on the "C:\"

    Actually, we named it "Z:\" and like I said, the files are on a server... not on the computer.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Try using the full UNC path, not the local path. So \\ServerName\Share\Folder\MyFile.txt rather than Z:\MyFile.txt

  11. #11
    Forum Contributor
    Join Date
    06-04-2013
    Location
    Moscow
    MS-Off Ver
    Office 365
    Posts
    100

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Try instead the disk name to use IP of the disk: "\\192.168.1.1\Owner\My file.txt"

  12. #12
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    So I put my attachment on my desktop to make a test... and it still don't work

  13. #13
    Registered User
    Join Date
    11-04-2014
    Location
    Paris
    MS-Off Ver
    2010
    Posts
    8

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    still not working

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: MAIL.AddAttachment (Sheets("MAIL").Range("N17").Text) <---- Why is it not working?

    Hello VBAzr,

    Try changing the SMTP port numberfrom 25 to 445.
    Please Login or Register  to view this content.

+ 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] Range("A1") = Sheets("Sheet2").CenterHeader.Text doesnt work.
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2013, 07:06 AM
  2. Replies: 0
    Last Post: 11-20-2012, 10:22 AM
  3. Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" not working
    By redders in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2011, 03:52 PM
  4. [SOLVED] "Send to Mail Recipient" icon not working
    By Lynde in forum Excel General
    Replies: 7
    Last Post: 06-23-2005, 12:05 PM
  5. Sending macro based e-mail with built-in "Heading" and "Text"
    By Prabha in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-17-2005, 11:06 AM

Tags for this Thread

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