Results 1 to 1 of 1

Sending Emails via Macro

Threaded View

  1. #1
    Registered User
    Join Date
    10-02-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question Sending Emails via Macro

    The purpose of this macro is to send an email when an X (used to denote a failed product) is placed in the O column, I have played around with several different ideas, but have yet to have any success. Here is a copy of the code, any help is appreciated!

    Private Sub Before_Close(ws As Worksheet, Cancel As Boolean)
    
        ws.Cells(1, 7) = 0
        Dim OutApp As Object
        Dim OutMail As Object
        Dim n As Integer
        n = 7
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
       
        With OutMail
            While (n < 50)
                If Worksheets("Areas Changed").Cells(n, 15) = "X" Then
                    .To = "jake.noble@roush.com"
                    .CC = ""
                    .BCC = ""
                    .Subject = "Engineering Change Altered Areas"
                    .Body = "The design for " & ws.Cells(3, 3) & " RMCC " & ws.Cells(4, 3) & " has failed checking."
                    ThisWorkbook.Save
                    .Attachments.Add ThisWorkbook.FullName
                    GoTo endSub
                Else
                    n 1 = n
                End If
           LOOP
        On Error GoTo failSection
            .Send
        End With
        
        If (0) Then
    failSection:
            MsgBox ("Could not send email to Processing. Please check your internet connection and try again.")
            ws.Cells(1, 7) = 1
        End If
        Set OutMail = Nothing
        Set OutApp = Nothing
    endSub:
    End Sub
    Last edited by arlu1201; 10-03-2013 at 12:45 AM. Reason: Use code tags in future.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Sending emails through macro
    By nbhatia4u in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2013, 08:01 AM
  2. [SOLVED] Sending Outlook emails from Excel; Limits to three emails only?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2013, 06:53 AM
  3. [SOLVED] HELP! Macro not sending emails
    By g1987 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-23-2012, 12:25 PM
  4. excel macro for sending emails
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 12-11-2009, 08:50 AM
  5. Sending macro emails using excel: Send emails with their passwords.
    By loveisblind in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 03:16 PM

Tags for this Thread

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