Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2023, 06:01 AM
TomWitsel TomWitsel is offline Auto generate new mail with attachment Windows 10 Auto generate new mail with attachment Office 2010
Novice
Auto generate new mail with attachment
 
Join Date: Mar 2023
Posts: 1
TomWitsel is on a distinguished road
Question Auto generate new mail with attachment

Greetings,



Is there a way to...

We send a mail to each of our service people on the road with their time-table data made in excel. We do this each month, always the same file to the same person and this for 20 people.

Is there a way to automate the creation of the mail and/or the adding of the file?

Thank you!
Reply With Quote
  #2  
Old 03-04-2023, 01:34 PM
AlanCantor AlanCantor is offline Auto generate new mail with attachment Windows 10 Auto generate new mail with attachment Office 2019
Competent Performer
 
Join Date: Nov 2020
Posts: 134
AlanCantor is on a distinguished road
Default

Maybe something like this?



Code:
Sub Email_Attachment_To_Group()
    Dim OutApp As Object
    Dim OutMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    With OutMail
        .To = "person1@email.com;person2@email.com"     ' List of addresses to send
        .CC = ""
        .BCC = ""
        .Subject = "Monthly spreadsheet"
        .Body = "Attached is the monthly spreadsheet."
        .Attachments.Add ("C:\Users\123456\Documents\Monthly\test.txt") ' Specify full path to the file to attach
        .Display
    End With
         
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
Reply With Quote
  #3  
Old 03-06-2023, 01:07 AM
gmayor's Avatar
gmayor gmayor is offline Auto generate new mail with attachment Windows 10 Auto generate new mail with attachment Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you have 20 recipients, mail merge would make sense. Assuming each employee has a different variation of the worksheet then you could use E-Mail Merge Add-in to merge to e-mail with the filenames and recipients taken from the datasheet.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto generate new mail with attachment Auto generate X pages from input lipatin Word VBA 12 06-01-2018 12:13 AM
How to auto-generate whole Powerpoint presentations from a set of data? olibot2000 PowerPoint 1 06-24-2017 09:01 PM
Auto Generate Invoice Number Word 2013 Jonah245 Word VBA 3 09-04-2014 05:24 PM
Auto generate new mail with attachment email as pdf attachment - subject line and attachment named after mail merge Nexus Mail Merge 12 04-13-2011 11:34 PM
Word attachment on an E-mail-macro to open attachment & nablady Outlook 0 11-28-2006 03:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:36 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft