Send Email (with Attachment) | Excel VBA Macro

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ต.ค. 2024

ความคิดเห็น • 102

  • @greggowaffles
    @greggowaffles  3 ปีที่แล้ว +1

    Send email with attachments from a list 🤓😎: th-cam.com/video/7imUc0YhfV0/w-d-xo.html

  • @chizzlemo3094
    @chizzlemo3094 3 ปีที่แล้ว +1

    I was about to buy that $50 app so I could add attachments to mail merge, you saved me!

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      Ayyeee!! Glad to hear that! Close call!!

  • @fredericlian7156
    @fredericlian7156 21 วันที่ผ่านมา

    Hello greggowaffles, how can we add the most recent file in Outlook among of several files?

  • @selvan1264
    @selvan1264 2 ปีที่แล้ว

    Thank you for the video. in this case how to include the code to save the outlook draft email into local folder 1st?

  • @JrIsHidden
    @JrIsHidden 2 ปีที่แล้ว

    I've watched a handful of attachments.add videos and this was the first one that worked for me! My only barrier now is to figure out how to choose what file within a specific file path. (multiple emails with multiple attachments corresponding to the contact im sending it to)

    • @greggowaffles
      @greggowaffles  2 ปีที่แล้ว

      So glad to hear that! Hope this playlist helps: Sending Emails
      th-cam.com/play/PLRixa5AJvj-SYr6vh9-AcG9YM8UuRpN5b.html

  • @zackd7597
    @zackd7597 7 หลายเดือนก่อน

    Can you use attachments.add with a file path that is specified by a file path manually entered into a certain cell?

  • @tstoneami
    @tstoneami ปีที่แล้ว

    Just what I needed - thank you.

  • @hashimali5255
    @hashimali5255 3 ปีที่แล้ว +1

    Watched a lot of videos but this one actually helped, thank you Sir!

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      No problem. Glad to hear that!!

  • @poojaghatge3855
    @poojaghatge3855 2 ปีที่แล้ว

    Hi Greg, this is wonderful however my attachments and body of the email is not displayed. Anything that you can suggest why that's happening?

  • @forestsunrise26
    @forestsunrise26 3 ปีที่แล้ว +1

    Brilliant! This worked out smoothly! Thank you very much!

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      No problem! So glad to hear that!!

  • @alteavanloggerenberg2464
    @alteavanloggerenberg2464 ปีที่แล้ว

    Hi, the files are not attaching in the mail. Any idea as to the reason? Thanks,

  • @kyguy4485
    @kyguy4485 2 ปีที่แล้ว

    Just what I was looking for!

  • @skimpylemon8034
    @skimpylemon8034 2 ปีที่แล้ว +1

    This is awesome! Thanks man! Can you do a video that shows how to add the 'Check Names' inside that code in cases where you have 20+ emails in the To and CC segments in an email?

  • @salimkoc4254
    @salimkoc4254 2 ปีที่แล้ว

    Hello, I want to export the selected area as jpeg or png in Excel. Can you help me. Thank you.

  • @chenvandersluijs8669
    @chenvandersluijs8669 3 ปีที่แล้ว +1

    Hi, I did everything like you did but I don't get the attachment into the email. What am i doing wrong?

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      hey! can you paste your code here so that i can take a look?

  • @rrki
    @rrki 2 ปีที่แล้ว

    Sir, I did step by step what you did and nothing was attached! Any idea why?

  • @callumwhelan4223
    @callumwhelan4223 ปีที่แล้ว

    Trying to upload the activeworkbook sharepoint link as a body attachment so that users when they receive the email can be directed to the sharepoint area. Any ideas?

  • @tet1473
    @tet1473 3 ปีที่แล้ว

    Hi Greg,
    Can I link .to and .Attachements.Add to a cell value?
    If yes how that can be achieved?

  • @mattperrizo1780
    @mattperrizo1780 3 ปีที่แล้ว

    I am getting stuck at the .Display portion of the VBA. Any suggestions on what might be causing this?

  • @tiareamezcua2756
    @tiareamezcua2756 3 ปีที่แล้ว

    How do you do it without saving the document? I have a read only form that I would like users to prefill and send but not replace original form

  • @kuljotsohal6402
    @kuljotsohal6402 4 ปีที่แล้ว +1

    Hello Greg,
    Is it possible to add another section where it would be sent out via a team email instead of my own person email. How would I go about this ? Thanks for the great video btw.

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +3

      hi. try this: .SentOnBehalfOfName = “team email”

  • @swapnil010283
    @swapnil010283 3 ปีที่แล้ว +1

    Thank you, this was fantastic.

  • @sundarsinghpthula
    @sundarsinghpthula 5 หลายเดือนก่อน

    How to attach only specific sheets in Excel

  • @davidlinton4127
    @davidlinton4127 2 ปีที่แล้ว

    Great thanks Greg!

    • @greggowaffles
      @greggowaffles  2 ปีที่แล้ว

      No prob! Thanks for watching!!

  • @timothylim8728
    @timothylim8728 2 ปีที่แล้ว

    This is amazing! quick question. does anyone know how to also include a hyperlink into the email body? like for question please email back "here"

    • @greggowaffles
      @greggowaffles  2 ปีที่แล้ว

      Thanks for watching! Hope this video helps: Excel VBA Macro: Send Email (with Hyperlink)
      th-cam.com/video/0kYmKFzMDiA/w-d-xo.html

  • @iangerardcapistrano5320
    @iangerardcapistrano5320 2 ปีที่แล้ว

    thanks for the video ☺

    • @greggowaffles
      @greggowaffles  2 ปีที่แล้ว

      No prob! Thanks for watching!!

  • @mylou12071
    @mylou12071 3 ปีที่แล้ว

    I am trying to create an automated system where I can email the customer statements. If I had a Pivot Table, how can I code it where it filters the Customer name based on the next loop and it then sends the table copy to the assigned email address. Let it loop to the next customer, which means it would filter the table again and sent that new table to the assigned email....etc. You made me understand the whole how to add a table to the email but If you can show a way to make my situation work, I would really really love to see it.

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      I'll make a video on that scenario as soon as I can! Thanks! You could combine the code/logic from this video with the one on sending a table: th-cam.com/video/7Chuqz5M65U/w-d-xo.html . Hope that helps and apologies for the late reply!

  • @kylesterling9176
    @kylesterling9176 2 ปีที่แล้ว

    Hey Greg, thanks for making this video it has been very helpful. One question: In your .HTMLBody portion you include the & .HTMLBody after the strBody. My strBody will not populate in the body of my email unless I remove this. If I remove this i do not get my signature at the end of the email unfortunately... any solution for me? Thanks

    • @greggowaffles
      @greggowaffles  2 ปีที่แล้ว +1

      Thanks for watching! Can you put the entire line of code here? I haven’t come across that issue before

  • @ALL_DAY_K
    @ALL_DAY_K ปีที่แล้ว

    Would loooove to know how to do this with SharePoint file paths instead of file paths for saved files🤔

    • @greggowaffles
      @greggowaffles  ปีที่แล้ว

      Hope this helps! th-cam.com/video/0kYmKFzMDiA/w-d-xo.html

  • @gajendrasingh9486
    @gajendrasingh9486 ปีที่แล้ว

    Can we send by Gmail

  • @joaogrilo4896
    @joaogrilo4896 ปีที่แล้ว

    Thanks for sharing! :D

  • @julioguzman3687
    @julioguzman3687 3 ปีที่แล้ว

    Great job. Thanks buddy.

  • @abdulmashood4646
    @abdulmashood4646 4 ปีที่แล้ว

    Hi Greg,
    Your lesson is very beneficial. Can I automatically convert the report from excel to pdf and send.

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +1

      Glad to hear that! Yes, you can!

  • @Tushar22011998
    @Tushar22011998 4 ปีที่แล้ว

    Hi Greg
    Thanks for this code
    But I am encountering a problem where the code is working fine, it even displays the mail before sending, but when I click send, it won't go to the recipient as well as there is no trail in my Sent item as well. Can you help me?

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว

      I've never heard of that before. There may be some sort of security preventing it from going through. Maybe try .Save instead of .Display or .Send and see if you can manually send it from your saved folder until you can determine what's actually blocking it. Hope that helps!

  • @MrBeckball
    @MrBeckball 4 ปีที่แล้ว

    Hi Greg,
    Amazing video-lesson. Is it possible to attach the active sheet (not whole book)?

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว

      Thanks! Yup, you can create a new workbook, add the active sheet to it and send that

  • @aubreyeikenberry8977
    @aubreyeikenberry8977 4 ปีที่แล้ว

    I want the attached file to come from a shared drive. Will the email recipient be able to directly save it to that location?

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว

      the recipient would have to manually save it to that location if you send the file as an attachment. if you reference the file in your email with a hyperlink, then the user will automatically be able to open and save directly to that shared drive location. apologies for the late reply

  • @randomtilfaeldig
    @randomtilfaeldig 3 ปีที่แล้ว

    Thank you for the great video! Just what I was looking for
    Is it possible to choose a different mail to send from? I manage several email accounts in my outlook and would like to choose a different one automatically. ".From = " does not work for me

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      No problem! Hope this video helps: th-cam.com/video/ybrlERsUXMQ/w-d-xo.html

  • @breebutler8489
    @breebutler8489 3 ปีที่แล้ว

    Are you able to attach a file based on a variable? (i.e. If cell A2 = "North" then send the workbook North.xlsx, if A2 = South then send South.xlsx)

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว

      yup, you would use something like
      .Attachements.Add "beginning of file path" & Sheets("Sheet Name").Cells(2,1).Text & ".xlsx"

  • @laurenmcintoshh
    @laurenmcintoshh 4 ปีที่แล้ว +1

    How would I add in an additional email address if I wanted to send to more than one person at a time?

    • @Tushar22011998
      @Tushar22011998 4 ปีที่แล้ว +1

      just do this after .to = "team@abc.com" & ";" & "team@def.com"

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +1

      Or .to ="team@abc.com; team@def.com" you can add up to 500 (I think) email addresses as long as you separate each with a semi colon

    • @laurenmcintoshh
      @laurenmcintoshh 4 ปีที่แล้ว

      greggowaffles perfect thank you solved my problem🙌🏽

    • @attachmonk6023
      @attachmonk6023 4 ปีที่แล้ว

      Go to 'Contacts', choose 'Home', and click 'New contact'. Set the name 'Undisclosed recipient' for the address you want to use for bulk emails as sender. Save your changes. Now to send email to multiple recipients you can just select created contact and add it into the 'To' box.

  • @kja0890
    @kja0890 3 ปีที่แล้ว

    Thank you so much!!! 🙇

  • @thecodfather7109
    @thecodfather7109 3 ปีที่แล้ว

    Thank you 🙏🏼

  • @khareemcarr8247
    @khareemcarr8247 4 ปีที่แล้ว

    What if the attachment is dynamic, meaning i already have a macro that saves the file to be attached as a date linked to a cell within the workbook, how would i go about having it attached? Helpful vid btw..

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +1

      Thanks! You would just set a variable (ex. myPath) equal to that path that you used to save the file, and then do .Attachments.Add myPath

    • @khareemcarr8247
      @khareemcarr8247 4 ปีที่แล้ว

      @@greggowaffles thanks for the timely response, I tried something like that but no attachment came up so maybe i did something wrong, i tried variable path="c:\documents
      ew weather report -" & format(activesheet. Range(a3), "mm-dd-yyyy") & ". Xlsx", fileformat=51 which saves the file but no luck, tried it without the file format and breaking it up into separate variables with path and filename separate..

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว

      @@khareemcarr8247 you can use MsgBox path to see exactly what path is equal to. There might be an issue with the formatting

  • @abhishek18286
    @abhishek18286 4 ปีที่แล้ว

    Can we attach Excel file in email and table at mailbody both at same time through Macro? If yes can you please prepare a video for same?

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว

      That's a good idea. Thanks! In the meantime, all you have to do is use the code from the other video and add the .Attachments.Add... line to it

    • @sushantmuduli6440
      @sushantmuduli6440 3 ปีที่แล้ว

      @@greggowaffles attachments do not work Greg

  • @22marykate
    @22marykate 4 ปีที่แล้ว

    Hi! Can the email address be dynamic and dependent on what email is input in a cell?

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +1

      Yup! This video gives an example relating to that: th-cam.com/video/7Chuqz5M65U/w-d-xo.html

  • @loliloucrew
    @loliloucrew 2 ปีที่แล้ว

    Thanks for the code and explanation !
    I've been struggling why attachment wasn't working ... I wrote Attachement instead of Attachment ... lost few hours on this hahahahaha

    • @greggowaffles
      @greggowaffles  2 ปีที่แล้ว

      😂😂 happens to the best of us. Glad you figured it out!!

  • @manju538
    @manju538 3 ปีที่แล้ว

    I want pickup the subject, to, body from excel sheet but not in range only specific cell ie sheet2 "A2"

    • @greggowaffles
      @greggowaffles  3 ปีที่แล้ว +1

      You could do ThisWorkbook.Sheets(sheet2).Cells(2,1).Text

  • @muratuslu1770
    @muratuslu1770 ปีที่แล้ว

    thanks a lot!!

  • @khareemcarr8247
    @khareemcarr8247 4 ปีที่แล้ว

    Is there a way to just open the path to the attachment for it to be selected?

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +1

      yes. if you search: "Application.FileDialog(msoFileDialogFilePicker)" you'll find code on selecting a file and storing the file path

    • @khareemcarr8247
      @khareemcarr8247 4 ปีที่แล้ว +1

      @@greggowaffles Thanks man!

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +1

      No prob!

  • @pradeepsg
    @pradeepsg ปีที่แล้ว

    super brother

  • @guruprasad5118
    @guruprasad5118 4 ปีที่แล้ว

    Also include the send option within Macro

    • @greggowaffles
      @greggowaffles  4 ปีที่แล้ว +2

      you can swap out ".Display" with ".Send" to do that

  • @notanotch1107
    @notanotch1107 2 ปีที่แล้ว

    Great Video,
    How would I send an attachment that references a cell in the active worksheet that has the file pathway instead putting it in "C:\destop
    eport\01.pdf
    ".
    I have the following code so far:
    A1= First Name
    B1= Last Name
    C1= To email address
    D1= CC
    E1= Subject
    F1= File Pathway
    Sub send_email_attachment()
    Dim EApp As Object
    Set EApp = CreateObject("Outlook.Application")
    Dim EItem As Object
    'Dim EApp As Outlook.Application
    'Set EApp = New Outlook.Application
    'Dim EItem As Outlook.MailItem
    'Set EItem = EApp.CreateItem(olMailItem)
    Dim path As String
    Dim RList As Range
    Set RList = Range("A2", Range("a2").End(xlDown))
    Dim R As Range
    For Each R In RList
    Set EItem = EApp.CreateItem(0)
    With EItem
    .To = R.Offset(0, 2)
    .CC = R.Offset(0, 3)
    .Subject = R.Offset(0, 4)
    .Attachments.Add = R.Offset(0, 5)
    .Body = "Dear " & R & "," & vbNewLine & vbNewLine _
    & "Please find attached your report. " & vbNewLine & vbNewLine & "Respectfully," & vbNewLine & vbNewLine & _
    "signature"
    .display
    End With
    Next R
    Set EApp = Nothing
    Set EItem = Nothing
    End Sub