+ Reply to Thread
Results 1 to 2 of 2

VBA to email the sender a copy of the message sent

  1. #1
    Registered User
    Join Date
    02-14-2013
    Location
    wales
    MS-Off Ver
    Excel 2010
    Posts
    64

    VBA to email the sender a copy of the message sent

    I have a VBA code that works perfectly fine sending emails to a series of address list in some cells using outlook as the application. What I am trying to achieve is to automatically send a cc copy of the email to the sender. Help would be greatly appreciated. Code below
    [CODE][/Sub Email_Sheet_only()

    Dim oApp As Object
    Dim oMail As Object
    Dim LWorkbook As Workbook
    Dim LFileName As String

    'Turn off screen updating
    Application.ScreenUpdating = False

    'Copy the active worksheet and save to a temporary workbook
    ActiveSheet.Copy
    Set LWorkbook = ActiveWorkbook

    'Create a temporary file in your current directory that uses the name
    ' of the sheet as the filename
    LFileName = LWorkbook.Worksheets(1).Name
    On Error Resume Next
    'Delete the file if it already exists
    Kill LFileName
    On Error GoTo 0
    'Save temporary file
    LWorkbook.SaveAs Filename:=LFileName

    'Create an Outlook object and new mail message
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItem(0)

    'Set mail attributes (uncomment lines to enter attributes)
    ' In this example, only the attachment is being added to the mail message
    With oMail
    .To = Sheet1.Range("c62").Value & ";" & Sheet1.Range("c63").Value & ";" & Sheet1.Range("c64").Value & ";" & Sheet1.Range("c65").Value & ";" & Sheet1.Range("c66").Value & ";" & Sheet1.Range("c67").Value '& ";"
    .CC = ""
    .Subject = "Trying to Work - "
    .Body = "To all concerned" & vbLf & _
    "Kind Regards"
    .Attachments.Add LWorkbook.FullName
    '.Display
    .send
    End With
    '
    '
    'Delete the temporary file and close temporary Workbook
    LWorkbook.ChangeFileAccess Mode:=xlReadOnly
    Kill LWorkbook.FullName
    LWorkbook.Close SaveChanges:=False

    'Turn back on screen updating
    Application.ScreenUpdating = True
    Set oMail = Nothing
    Set oApp = Nothing

    End SubCODE]

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: VBA to email the sender a copy of the message sent

    Maybe
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

+ 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. Getting SMTP Email Address of an Exchange Sender
    By RhettL in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2014, 11:12 PM
  2. Send Email but make sure they cannot reply to the sender
    By rpinxt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2014, 06:51 AM
  3. [SOLVED] Recovering the default sender outlook email address from vba on excel
    By Alain-79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2013, 03:53 AM
  4. Automatic email sender that only sends 2 oldest reord and then delete them
    By ayan1988 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2013, 04:43 PM
  5. Sending email using macro - using a specific sender
    By jhuang in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-24-2011, 09:16 PM
  6. Problem in Sending a test email to sender's own account.
    By J.wills in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 06-02-2009, 02:47 AM

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