+ Reply to Thread
Results 1 to 2 of 2

olMail - Email Attachment Variable. Sending Email through Excel

  1. #1
    Forum Contributor
    Join Date
    08-07-2014
    Location
    London
    MS-Off Ver
    10
    Posts
    148

    olMail - Email Attachment Variable. Sending Email through Excel

    Hi all... this is my first post and help is needed. I am creating a spreadhseet which I can send emailed reports through. I can send the reports but need the olmail.Attachments.Add to work as a variable. As in, I need to be able to change the name of the file. For example I might send January.xlsx but I want the ability for the code to point to excel (like I've done with range as shown in the code) and a specific cell in which I can put February and it will will then look for and attach the February file instead of January. I hope that makes sense.

    Sub SendEmail()
    '
    ' SendEmail Macro
    '

    '
    Dim olApp As Outlook.Application
    Set olApp = CreateObject("Outlook.Application")

    Dim olMail As Outlook.MailItem
    Set olMail = olApp.CreateItem(olMailItem)

    olMail.To = Range("XFA1")
    olMail.CC = Range("XFB2")
    olMail.Subject = Range("G13")
    olMail.Body = Range("G17")
    olMail.Attachments.Add ("\\RB-BIR-FS1\viewhome\snawaz\Desktop\Corp\(insert variable?)")
    olMail.Send

    End Sub

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: olMail - Email Attachment Variable. Sending Email through Excel

    http://www.excelforum.com/excel-prog...ugh-excel.html & http://www.excelforum.com/showthread...17#post3843117

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. OlMail - Variable Attachment Option. Sending Emails through Excel
    By ShakJames in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2014, 06:54 AM
  2. [SOLVED] Sending attachment in email using vba
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-18-2014, 10:02 AM
  3. sending an Excel worksheet as an xls attachment through email
    By grammadolly9 in forum Excel General
    Replies: 2
    Last Post: 02-15-2013, 03:51 AM
  4. [SOLVED] Sending email with attachment
    By Nu2Java in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2012, 04:15 PM
  5. Sending email attachment(s) from Excel 2007
    By nobleprince in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-28-2010, 12:33 PM

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