Closed Thread
Results 1 to 18 of 18

Create E-mails in a G-Mail account with attachments using VBA

  1. #1
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Create E-mails in a G-Mail account with attachments using VBA

    Hi Experts,

    I’m requesting for some help to be able to create G-emails using Excel (VBA). My request is primarily to be able to attach excel files.

    I've attached a sample of my template that will have all the necessary information that I need to relay.

    I’ll be happy to provide all / more information. Please advise.

    Best regards,
    Spi
    Attached Files Attached Files
    Last edited by spiwere; 02-06-2013 at 08:56 AM.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Create E-mails in a G-Mail account with attachments using VBA

    spi,

    most of your requirements should be covered in the attached workbook. GMail is blocked at work (the smtp ports), so I cannot test. Like I mentioned before "Save as Draft" is not supported by cdo.
    Attached Files Attached Files
    If you like my contribution click the star icon!

  3. #3
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Thank you Sir!

    I changed the [email protected] to my address. Populated some of the fields "To" and "CC", Subject body etc...

    I also chaged the port number (valid smtp port numbers are 25, 465, 587), but on running I faced the following error:

    Please Login or Register  to view this content.


    Please advise.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Create E-mails in a G-Mail account with attachments using VBA

    I should have tested a bit more before posting. sorry. A new/revised version is attached.
    Attached Files Attached Files

  5. #5
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    No problems at all!

    But now on my run I'm facing a new error..

    Please Login or Register  to view this content.
    Maybe, Its to do with the our server settings. I'll get this checked once my IT folks are back in tomorrow. They are off and I'm only here to get this going.

    Thanks!

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Create E-mails in a G-Mail account with attachments using VBA

    This is a known problem with this method. Try the different port numbers

  7. #7
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Its a miracle or no less than that OllieB.

    Just a one question that comes up from my preliminary run is about adding attachments. How should that happen? I have about 200 excel files in a folder. Each one is to be sent to a separate set of recipients.

    Thanks again!

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Create E-mails in a G-Mail account with attachments using VBA

    spi, to add an attachment just type the full qualified path to the object you would like to attach. So for example an entry of "c:\temp\abc.xls" in column L would attach that spreadsheet to the e-mail being send.

  9. #9
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Yes, I think I had guessed it after I wrote the last post. It is working fine. I'll do a more comprehensive run once I get back to close this thread or seek any help.

    Thanks again!

  10. #10
    Registered User
    Join Date
    04-30-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2013
    Posts
    59

    Re: Create E-mails in a G-Mail account with attachments using VBA

    I absolutely love this functionality. It is exactly what I need.

    Unfortunately, when I run the macro the email just contains the text of the path but not the attachment. Any ideas?

  11. #11
    Registered User
    Join Date
    04-30-2012
    Location
    Missouri
    MS-Off Ver
    Excel 2013
    Posts
    59

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Nevermind. Got it!

  12. #12
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Hey Jph,

    Sorry for the late reply. I think you have been able to resolve it. In any case, for adding an attachment please type the complete path of the desired file you would like to attach. So for example an entry of "c:\temp\abc.xls" in column L would attach that spreadsheet to the e-mail being sent.

    Thanks!

  13. #13
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Dear OllieB,

    I'm running this and everything seems to be in place till now. The finalization at my end would take sometime as the CDO limitation to generate drafts forces me to incorporate everything on this excel and be more than 100% sure, and believe me with the humungous data I have it isn't going to be that easy. I'm up for a good few days of extra work. But your solution is Awesome!!!

    Just one quick thing: How can one add a Send and an Attach button onto the this. Right above the header would do.

    Thanks!

  14. #14
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Create E-mails in a G-Mail account with attachments using VBA

    spi, you can try this yourself quite easily. Go to the Developer tab on the ribbon, and click Insert. Select the button image under Form Controls. Draw the button where you want it to be and you will automatically be prompted to select the macro you want to attach to the button. Not sure what you would like to do with the Attach button though

  15. #15
    Forum Contributor spiwere's Avatar
    Join Date
    01-11-2013
    Location
    IN
    MS-Off Ver
    Excel 2007
    Posts
    410

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Thanks OllieB!

    All is well. I'm going ahead and closing the thread as "Solved"

    Best regards,
    Spi
    Last edited by spiwere; 02-07-2013 at 06:58 AM.

  16. #16
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Spi, please remember to click on the star icon if you are happy with my contribution! Thank you

  17. #17
    Registered User
    Join Date
    05-26-2017
    Location
    tyrone
    MS-Off Ver
    2007
    Posts
    1

    Re: Create E-mails in a G-Mail account with attachments using VBA

    Hey I've been searching the net for a code that works I toy with it just to get work emails to send through excel. I'm using the code you attached which covers most of my needs. I've cleared all the references to the cell on the to section just to the email I want to send to this works. I've tested the attachment section by adding a pathway to another file just to see If I can send with an attachment and this worked. I have linked the macro to a command button which I would like to use when i'm finished with the workbook. I want it to effectively save the workbook and then send it on using your code

  18. #18
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Create E-mails in a G-Mail account with attachments using VBA

    @peter

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

Closed Thread

Thread Information

Users Browsing this Thread

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

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