Results 1 to 1 of 1

Send Email when I press "Send" button in Outlook

Threaded View

  1. #1
    Registered User
    Join Date
    08-07-2014
    Location
    Canada
    MS-Off Ver
    2010
    Posts
    95

    Send Email when I press "Send" button in Outlook

    I have coded an automatic process of sending multiple emails in excel VBA. But I don't want each email to be sent until I press "Send" button in Outlook by myself. For example, there are 3 persons I need to send email. The macro generates and displays the email for the first person and wait for me to press the "Send". When I press the "Send", the macro loops to next person and displays the email and wait for me to send.

    I don't know how to write this code for allowing me to press "Send" button in Outlook and then trigger next round.

    Here is my code. Thank you very much.
    Sub MultiEmailSend()
    
        Dim row_number As Integer
        Dim OutApp As Object
        Dim OutMail As Object
        Dim AttachFile As Range
        Dim OutWordEditor As Object
        
        Dim WordDoc As Object
        Dim WordFile As String
    
        Dim FileFolder As String    'The folder for thisworkbook
        Dim Fname As String
        
        Dim EmployeeN As String
        Dim rngSearch As Range      'The range which to search in
        Dim rowFirstFind As Integer 'Return the first row# where the EmployeeN is found
        Dim CountN As Integer       'Return the number of the same EmployeeN
        Dim rngAttach As Range      'Return the range of attachment of certain EmployeeN
        
        
        
        FileFolder = ThisWorkbook.Path
        Sheets("Attachment List").Range("C2") = FileFolder
    
        Set OutApp = CreateObject("Outlook.Application")
        
        'Get word file and copy content
        WordFile = Application.GetOpenFilename(Title:="Select MS Word file", MultiSelect:=False)
        Set WordDoc = GetObject(WordFile)
        WordDoc.Content.Copy
        'WordDoc.Close
       
        row_number = 1
       
        Do Until row_number = 3
           row_number = row_number + 1
        
           'Get the range of attachments on sheets("Attachment List") of certain Employee
           EmployeeN = Sheets("Home").Range("A" & row_number).Value
        
           Set rngSearch = Sheets("Attachment List").Range("A:A")
           rowFirstFind = rngSearch.Find(What:=EmployeeN, LookIn:=xlValues, LookAt:=xlWhole, _
             SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Row
            
           CountN = Application.WorksheetFunction.CountIf(Sheets("Attachment List").Range("A:A"), EmployeeN)
        
           Set rngAttach = Sheets("Attachment List").Range("D" & rowFirstFind).Resize(CountN, 1)
        
           'Create new email
           Set OutMail = OutApp.CreateItem(0)
           Set OutWordEditor = OutMail.GetInspector.WordEditor
        
           'Paste content from word to email body
           OutWordEditor.Content.PasteAndFormat Type:=wdFormatOriginalFormatting
        
           'Writing an email
           With OutMail
              .BodyFormat = olFormatHTML
              .To = Sheets("Home").Range("B" & row_number).Value
              '.CC = ""
              '.BCC = ""
              .Subject = Sheets("Home").Range("E" & row_number).Value
              For Each AttachFile In rngAttach     'Attach attachments
                  .Attachments.Add AttachFile.Value
              Next AttachFile
              .Display
           Application.CutCopyMode = False
           End With
        
           Set OutMail = Nothing
           Set AttachFile = Nothing
           Set rngAttach = Nothing
        
           With Sheets("Home").Range("A" & row_number).Interior 'Highlight the EmployeeN which has been sent
               .Color = 5296274
           End With
        Loop
        
           Set OutApp = Nothing
    End Sub
    Last edited by qzqzjcjp; 06-27-2015 at 01:53 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Disabling or interrupting "send email attachment" in excel 2010
    By andrewgarcia86 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2013, 02:14 PM
  2. How to create a "send email" event once a field is modified?
    By DatacomGuy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-27-2013, 11:56 PM
  3. Managing "delegated tasks" in an Outlook "Send Only" account
    By on_way_to_fame in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 08-13-2013, 12:21 AM
  4. [SOLVED] send sheet automatically via Outlook wihtout clicking on "send"
    By aucho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-09-2013, 06:27 PM
  5. Replies: 2
    Last Post: 07-11-2005, 12:05 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