Send Email From Excel Using VBA & Gmail

Sdílet
Vložit
  • čas přidán 4. 06. 2013
  • This tutorial shows you how to use CDO to send an email from within Excel!
    Code here:
    brettdotnet.wordpress.com/2013...

Komentáře • 74

  • @averyscott7504
    @averyscott7504 Před 9 lety +1

    Thanks for posting this. I think the port may have changed since you originally posted this. I switched mine from 25 to 465 and it fixed my problem.

  • @michaelelkin9542
    @michaelelkin9542 Před 5 lety

    Thank you this is fantastic. I have tried many different code samples and every one failed at some point with a strange error. This one just works. Thank you very much. I also enabled Less Secure Access on my gmail. I found it on another sites instructions. I don't know if it is needed, but I know that it works. Thanks again.

  • @lokeshn8850
    @lokeshn8850 Před 11 lety

    hi just wanted to know if we write a software package with excel/ access for the background processing; do we infringe any terms with mocrosoft?
    also, what could be the limitations of writing an accounting software with excel/access as background processing instead of using c, java etc?

  • @MichaelDaniels
    @MichaelDaniels Před 10 lety

    Is there a way to do this from within a Worksheet you just saved?
    Example I want the attachment to be the current path.... current spreadsheet.... and a name I have created. I have all the path and names DIM as I am supposed to It just won't allow it for some reason? I even save the file name before I try the send email section.

  • @RahulGupta-tt3mj
    @RahulGupta-tt3mj Před 4 lety

    Hi,
    I want to ask that can we send data from excel sheets in same way they are formatted ? or the few range of cells ?

  • @rypi5489
    @rypi5489 Před 10 lety

    Hi Brett, thanks for the Top Tutorials. Is it possible to show a progress bar while the email is being sent so the end user knows something is happening? If this can be done can you offer some help?

  • @amartin4423
    @amartin4423 Před 11 lety

    Love your videos Brett! Thank you!!

  • @tranejones1018
    @tranejones1018 Před 7 lety

    hi, I would like to attach the last date modified file (automatically), how can I do that? thank in advance!!

  • @paulthayer4915
    @paulthayer4915 Před 4 lety

    DontFretBrett, I am getting an error about COM+ not being installed. Is that an Excel add on that I need in order for this to work?

  • @jnwte
    @jnwte Před 8 lety

    Subscribed, awesome channel Brett! Automation is key in a busy world and these videos are very helpful. I've already got email automation with the Outlook object library working but it's cool to see you can do this without Outlook. Thanks :)

  • @harrisonwoodard6721
    @harrisonwoodard6721 Před 9 lety

    Hey Don,
    I keep getting the "The transport failed to connect to the server" error. Any thoughts on what it may be. I've tried changing to port number to 465 and 587, but I still got the same error.
    Regards,

  • @SaurabhSingh-qr8bu
    @SaurabhSingh-qr8bu Před 8 lety

    Hi Brett I am trying the same but it is showing 3265 runtime error. Can you please help me on this

  • @MushtaqRedefined
    @MushtaqRedefined Před 11 lety

    Can you tell me how to send the particular sheet where the button has been place.

  • @DanielDauenbaugh
    @DanielDauenbaugh Před 10 lety

    I'm assuming the signature line setup through gmail will not be automatically included, but will need to be coded in? Is that correct?

  • @trungdung215
    @trungdung215 Před 9 lety

    i have a error.
    Run-time '424' Object required
    it stop in: config(cdoSMTPserver)="smtp.gmail.com"
    WHY?

  • @merijndimmendaal5407
    @merijndimmendaal5407 Před 9 lety

    Sorry, I'm really new to VBA...
    In excel i have a colum with emailadresses and next to it a colum with a personalized text. I want to send a the personalized text to the correct emailadress. How do i do that?
    Thanks in advance

  • @boggulasivakumar3057
    @boggulasivakumar3057 Před 8 lety

    I had did what u showed in the video but i did't get mail.... This code working correct but i am not received mail.
    Pls reply asap . Thank U

  • @ToZobg
    @ToZobg Před 10 lety

    I just did it on windows 7 64 bit .. it works PERFECTLY

  • @guillaumeberube2905
    @guillaumeberube2905 Před 9 lety

    Works perfectly. Thanks veru appreciate

  • @mazarsmr4721
    @mazarsmr4721 Před 10 lety

    Thank you Sir, very powerful Coding
    Can I ask how to insert selected range of cell to the content of gmail?? (not as attachement)

  • @RobGoldstein
    @RobGoldstein Před 4 lety

    this is great. Is there a way to combine this with a mail merge?

  • @ToZobg
    @ToZobg Před 10 lety

    Dude... 10x .. I love you :)

  • @FawadK1
    @FawadK1 Před 10 lety

    hey, thanks for the straight to the point video.
    Can I ask what the Config(cdoSMTPServerPort) = 25 does?
    if you could explain what the 25 is please.
    I have put together a code which highlights due dates X days in advance and speak out the notification msg. I would like to also use your code to send emails to those responsible for the tasks/due dates.
    Could you do a video on such a thing please ? :)
    Please and thank you.

  • @mittapalli1990
    @mittapalli1990 Před 4 lety

    Run time error object 424 coming. In line Set Config = Mail.Configuration, what to do?

  • @navneetsinghal3289
    @navneetsinghal3289 Před 6 lety

    It says "Automation Error". What to do!

  • @dreamsail7
    @dreamsail7 Před 10 lety

    Thanks, nice tool...

  • @mashudi4205
    @mashudi4205 Před 8 lety

    thank you for your video

  • @sivajivenni9365
    @sivajivenni9365 Před 9 lety

    i an getting error 91 and Set Config = mail.Configuration is getting highlighted. please help me. Thanks

  • @alialmatos268
    @alialmatos268 Před 3 lety

    Hello Good day Thanks for the video , I catered the code but I received message object required , how to solve ?

  • @samcx6939
    @samcx6939 Před 10 lety +1

    Your vedio is so helpful!! Hope that you can upload more vba teaching vedio!!

  • @mikepfly2
    @mikepfly2 Před 10 lety

    Don, very helpful video. Was looking for an easy way to do this, thanks. Mind if I ask what screen capture tool you use?

  • @halane7075
    @halane7075 Před 8 lety

    Thank you for your video! However I have one problem. When i run the code I receive the following error: The transport failed to connect to the server. Could you please help me on this! Thank you

    • @adamk.3690
      @adamk.3690 Před 8 lety

      I have the same : error: The transport failed to connect to the server.

  • @ChyounesYouness
    @ChyounesYouness Před 11 lety

    thanks you

  • @Darioq57
    @Darioq57 Před rokem

    Is that actually VBA? This sub will not go passed the first line without an error, starting with Dim Mail as New Mail.

  • @tanmoyd
    @tanmoyd Před 5 lety

    I am getting this error -2147220975 - can you help?

  • @sravanthk2449
    @sravanthk2449 Před 6 lety +1

    The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available
    Let me know what to do

    • @nitrame
      @nitrame Před 5 lety

      It could be that you are using 2-step verification on your Google Account. If yes, you will need to use an App Password.

  • @DanielKimbril
    @DanielKimbril Před 11 lety

    I am getting an error on this part of your your code here
    Config(cdoSMTPServer) = “smtp.gmail.com”
    error says,
    Run-time error '424':
    Object required
    Any Suggestions?

    • @dhillandhillan9121
      @dhillandhillan9121 Před 6 lety

      Daniel Kimbril
      Hii did you find solutions
      Even I got same error

    • @justiceshivambu7086
      @justiceshivambu7086 Před 4 lety

      @@dhillandhillan9121 Change those quote marks, they are different from what VBA uses

  • @luiscalixto4523
    @luiscalixto4523 Před 10 lety

    Great presentation!!!
    I exactly copied your script, ran it, and unfortunately, I got this Run-time error ‘3265’: "Item cannot be found in the collection corresponding to the requested name or ordinal."
    Config(cdoSMTPServer) = "SMTP.gmail.com"
    Config(cdoSMTPport) = 25
    May you please assist on what cdoSMTPport to use? Thank you.

  • @bytesize6220
    @bytesize6220 Před 7 lety +1

    to those who are getting server rejection errors, try logging out of your gmail accounts before running the code and use smtp port 465.

    • @fidei9257
      @fidei9257 Před 7 lety

      thanks. ive been figuring it out for too long y i cant send my emails.. y is it that port 25 not working right now?

    • @sparjhonarnejo6234
      @sparjhonarnejo6234 Před 6 lety

      Hi!...thank you very much for this! it was successful!

    • @riverlakesmotel8101
      @riverlakesmotel8101 Před 5 lety

      Not working for me, could you give more detail?

  • @GiselaGonzalez100
    @GiselaGonzalez100 Před 10 lety

    Mine did't work, I did it exactly as you did.

  • @edwinccalle55
    @edwinccalle55 Před 10 lety

    Thank you it is a very nice video. Can you please help me I'm trying to do the same with Outlook I will appreciate your help

  • @aabb135790
    @aabb135790 Před 10 lety

    It showed me an error saying "Object required." I did the exact same work, though. What should I do?

    • @DontFretBrett
      @DontFretBrett  Před 10 lety

      What line did it highlight

    • @jeffreydecker3189
      @jeffreydecker3189 Před 10 lety

      DontFretBrett Same thing for me. It highlighted Config (cdoSMTPServer) = "smtp.gmail.com"

  • @Me2023abc
    @Me2023abc Před 9 lety

    What about doing the same for yahoo ?
    Any server Info ?

    • @Me2023abc
      @Me2023abc Před 9 lety

      Eslam Omar Keep getting Run time error 3265

  • @MarcelBennett
    @MarcelBennett Před 6 lety

    Not sure if you respond to messages on this video. I'm helping my girl organize her client list in excel and one of the things we would like to do is to send a mass promotional email out to her clients emails (more than one client) via gmail. The idea would be to have a field in excel where we write the message then hit send and it would populate the receiver email from the database and send it out individually.

    • @DontFretBrett
      @DontFretBrett  Před 6 lety

      Mailchimp allows 2k subscribers, 12k emails a month for free, might be worth checking out. Probably allows excel / csv upload. Otherwise you could use the solution in the video but looping thru a list sending one at a time. This might work: (didnt test)
      Mail.From = Config(cdoSendUserName)
      Mail.Subject = “Subject from VBA”
      Mail.HTMLBody = “Body from VBA”
      Dim i as integer
      Dim lastrow as integer: lastrow = activesheet.range("A100000").end(xlup).row
      for i = 2 to lastrow
      Mail.To = “your_recipient@whereever.com”
      Mail.Send
      application.statusbar = i & " of " & lastrow
      doevents
      next i

    • @DontFretBrett
      @DontFretBrett  Před 6 lety

      oops Mail.To = activesheet.range("a" & i).value (or whatever column the email is in)

  • @muntkiminamdar30
    @muntkiminamdar30 Před 5 lety

    the message could not be sent to the smtp sever....this error is fessing

  • @Taki241
    @Taki241 Před 8 lety

    Hi guys if somebody still has a problem with the smtp ports try using 465 instead of 25 (it works for me)

    • @MalinaC
      @MalinaC Před 8 lety

      +Taki241 465 worked! Thanx a lot!

  • @DontFretBrett
    @DontFretBrett  Před 10 lety

    Correct Daniel, the signature wouldn't get automatically appended

    • @DanielDauenbaugh
      @DanielDauenbaugh Před 10 lety

      Thank you for the video and the reply. Greatly appreciated. Keep up the good work.

  • @user-fe2oh8oj2u
    @user-fe2oh8oj2u Před 6 lety

    I have 2 questions:
    1. How to display email before sending it ? It is important as I want to make adjustments and then click "send".
    2. How to attach current open excel from which macro is written and which does not need to be saved after being emailed?

    • @johnwhite3270
      @johnwhite3270 Před 6 lety

      I'm not sure this is correct, but try (Mail.display) before (Mail.send). Worth a try.

    • @ianreeve3200
      @ianreeve3200 Před 6 lety

      I too would like to do this. Did you find a way? If so please tell. Thanks

  • @sivabharath9478
    @sivabharath9478 Před 4 lety

    Run time error 13

  • @hanshima_
    @hanshima_ Před 4 lety

    Not possible anymore, google made the SMTP server available only for G Suite customers. But thanks for the code.

  • @nuramoboy
    @nuramoboy Před 9 lety

    I have watched many video all they lack something,why would u use all that steps to send email writing down all the code every time? so poor I am sorry why not sending direct from your email,I actual want to send group email just click without going those 100 steps