Consulting

Results 1 to 2 of 2

Thread: Email VBA code that CC's sender?

  1. #1
    VBAX Newbie
    Joined
    Sep 2015
    Posts
    1
    Location

    Email VBA code that CC's sender?

    Hi guys,

    I have a VBA code I am using for an excel spreadsheet that I am setting up in which several users will have their own copy. Once the information in the spreadsheet is completed, the user will click a button which will send an email to the intended recipient ( to be referenced in the code). However, I wanted to know if it is possible top modify this code so that the CC line automatically picks out the users email address (outlook), so that way when the user sends the email they also receive a copy as confirmation of the email being sent.
    Please see the code below. Any help will be much appreciated.

    Thanks!

    Sub Mail_workbook_Outlook_1()
    'Working in Excel 2000-2013
    'This example send the last saved version of the Activeworkbook
    'For Tips see:
    Dim OutApp As Object
    Dim OutMail As Object


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    On Error Resume Next
    With OutMail
    .to = ""
    .CC = ""
    .BCC = ""
    .Subject = ""
    .Body = ""
    .Attachments.Add ActiveWorkbook.FullName
    'You can add other files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    welcome to the forum.

    please wrap your code with code tags.
    paste and select your code and click # button.

    what is wrong with sent items?

    perhaps:
    .CC = OutApp.GetNamespace("MAPI").Session.CurrentUser.AddressEntry
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •