Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:34:56+00:00 2026-06-04T05:34:56+00:00

I am trying to send some files from a folder to a fixed email

  • 0

I am trying to send some files from a folder to a fixed email address, the files need to be sent in individual emails, the file names are random.

This topic got me started:

Send individual emails to predefined set of people with all files in a folder

I altered the code a tiny bit to suit my needs, but when I run the macro it isn’t sending the files. I’m sure its a simple mistake but my knowledge is limited!

This is my code:

Option Explicit

Const SOURCE_FOLDER As String = "C:\Users\Me\Desktop\Test"
Const RECIP_A As String = "me@hotmail.com"
Const EMAIL_BODY As String = "Please find attached file. Thanks and Regards, ABC"

Sub SendPDFs()
    On Error GoTo ErrorHandler

    Dim fileName As String
    fileName = Dir(SOURCE_FOLDER)

    Do While Len(fileName) > 0
        Call CreateEmail(SOURCE_FOLDER & fileName)
        fileName = Dir
    Loop

ProgramExit:
    Exit Sub
ErrorHandler:
    MsgBox Err.Number & " - " & Err.Description
    Resume ProgramExit
End Sub

Function CreateEmail(fileName As String)
    Dim olApp As Outlook.Application
    Dim msg As Outlook.MailItem

    ' create email
    Set olApp = Outlook.Application
    Set msg = olApp.CreateItem(olMailItem)

    ' set properties
     With msg
        .Body = EMAIL_BODY
        .Recipients.Add (RECIP_A)

        .Attachments.Add fileName
        .Send
    End With
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:34:57+00:00Added an answer on June 4, 2026 at 5:34 am

    Ah! The only problem with the code is

    Const SOURCE_FOLDER As String = “C:\Users\Me\Desktop\Test”

    Change that to

    Const SOURCE_FOLDER As String = "C:\Users\Me\Desktop\Test\"
    

    Now try it. I tried and tested it and it works.

    Also ensure that you have added reference to the Outlook object library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send some text in an email from my cocoa app
I've been trying to send an email from my magento module but for some
I've trying to send some infromation to a php file and display the result
Trying to send some email in my C# app. I am behind a proxy
I am currently trying to send some data from and Android application to a
I'm trying to send email with some images attached in django. Code used is
I am trying to send data from an Android app to a PHP file
I am trying to send audio file from one computer to other using socket
I am trying to send the files from an Android project so that a
Hello there im trying to send files using client-server classes in java. For some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.