Thursday, March 31, 2016

Troubleshoot:Adding Cell Values to a Macro when sending an email

Adding Cell Values to a Macro when sending an email

Hello All,
  I have a macro where I need to add 2 cell values when the email is triggered.
I can't get my code to pick up the needed cells and not sure where I'm going wrong.
Here's the code I have written and the worksheet I'm trying to pull the data from:
 
Sub Test5()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range
    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")
    On Error GoTo cleanup
    For Each cell In Columns("j").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" And _
           LCase(Cells(cell.Row, "f").Value) = "yes" _
           And LCase(Cells(cell.Row, "g").Value) <> "sent" Then
            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "Reminder"
                .Body = Cells(cell.Row, "A").Value _
                      & vbNewLine & vbNewLine & _
                        "Please note the Named Associate is on an Intermittent FMLA  " & _
                        "with effective date("d") and reason('h")."
               
               
                .Send
            End With
            On Error GoTo 0
            Cells(cell.Row, "g").Value = "sent"
            Set OutMail = Nothing
        End If
    Next cell
cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub
 
J represents the email address I'm sending to.
F represents the trigger, when "yes" send the email
G represents "sent" so the email is only sent once
A represents the employees name
 
I need to insert value from cell D - the effective date and cell H - the reason.
I need the body of the email to say:
 
Please note the Named Associate is on an Intermittent FMLA  the with effective date(cell d) and reason( cell h).
 
So in the case of John Doe it would say: Please note the Named Associate is on an Intermittent FMLA  the with effective date 8/15/2013 and reason Care of Mother.
 
So in the case of Mary Jane it would say: Please note the Named Associate is on an Intermittent FMLA  the with effective date 8/16/2013 and reason Personal Care.
 
Here is my worksheet if needed: Hope I was clear enough but I'm at my wits end trying to get this to work.
 

Associate
Manager
FMLA Type:   I=Intermittent 
R=Reduced
FMLA Effective Date
 Date Paperwork Requested from Bethpage
FMLA Type Trigger
FMLA Type Trigger - Sent
Reason

John Doe
 
I
8/15/2013
9/1/13
YES
sent
Care for Mother

Mary Jane
 
I
8/16/2013
9/2/13
YES
sent
Personal Care

Anwsers to the Problem Adding Cell Values to a Macro when sending an email

Download Error Fixer for Free Now

Hi Tigershoes,

Try this, I am not saying it is already what you need but at least I had some return of it.

HTH

Wkr,

JP Ronse

Sub Test5()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("j").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" And _
           LCase(Cells(cell.Row, "f").Value) = "yes" _
           And LCase(Cells(cell.Row, "g").Value) <> "sent" Then

            Set OutMail = OutApp.CreateItem(0)

            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "Reminder"
                .Body = Cells(cell.Row, "A").Value _
                      & vbNewLine & vbNewLine & _
                        "Please note the Named Associate is on an Intermittent FMLA  " & _
                        "with effective date: " & Cells(cell.Row, "C") & " and reason: " & Cells(cell.Row, "H") & "."
              
              
                .display
            End With
            OutMail.display
            On Error GoTo 0
            Cells(cell.Row, "g").Value = "sent"
            Set OutMail = Nothing
        End If
    Next cell

cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

Using Windows troubleshooter:

  • Click on Search on Charm bar and type Troubleshooting. Click on the very first option.
  • A new window will open. Click View all from the left pane.
  • Scroll down to the bottom and click on Windows update.
  • Troubleshooter window for Windows update will pop up. Click on NEXT. It may ask you for administrative permission.
  • The troubleshooter will automatically detect problems and fix it.
  • Now, close this window and try download/install the app which was previously showing error.

Another Safe way to Fix the Problem: Adding Cell Values to a Macro when sending an email:

How to Fix Adding Cell Values to a Macro when sending an email with SmartPCFixer?

1. Download Error Fixer. Install it on your system.

2. After the scan is done, you can see the errors and problems which need to be repaired.

3. The Repair part is done, the speed of your computer will be much higher than before and the errors have been removed. You can also use other functions in SmartPCFixer. Like dll downloading, windows updating and print spooler error repair.


Related: How to Fix - 64g ssd with a 500g regular drive?,Allow Unhide Rows in Protected Workbook [Solved],[Solved] Get in Excel 2007 data from Access 2007 out of self-built Queries,[Solution] How can I temporarily disable 'service manager' to install Adobe flashplayer?,[Anwsered] When I try to watch a flash video, I am told occasionally that I don't have Adobe Flash.,Solution to Error: Black screen during boot sequence,[Solved] Can't restore Windows 7 64-bit from external hard drive,How to Fix - IE 11 Enhance Protect Mode reset issue with add-on's?,Solution to Error: Internet Explorer 9 update/install error - Error Code 80092004,Upgrading to IE 8 causes cookies to get deleted when starting IE [Anwsered],Solution to Problem: All programs try to start from windows component
,Troubleshoot:External Hard Drive not listed in Windows 7 backup wizard Error
,How to Fix Error - Getting an error "not connected to the internet" while trying to install Samsung Kies?
,How to Fix - Internet Explorer shuts down and reopens tab when attaching to email or uploading files.?
,Fast Solution to Problem: Sending Error Message
,[Anwsered] Thinkpad 8611 Boot,How to Resolve - Svchost Helper?,Fast Solution to Problem: L30 101 Driver Windows 7,Troubleshooter of Error: Io Device,How to Fix Error - Dell Laptop Code 39?
Read More: How Can I Fix - After having my computer repaired by Comantra, I am unable to send any e-mails.?,[Solved] adobe flas for 64 bit windows 7,How to Fix - Adding a character to a line based on the existence of another character.?,How Can I Fix - Adobe reader 9.1 - not working since upgrade to IE8, cannot uninstall or upgrade?,[Solution] Adobe acrobat 7.0 professional - internal error 2350__Adobe acrobat 7.0 professional - error 1335,a file called mDNSResponse.exe. is causing bonjour not to operate properly,what should I do?,A QUESTION USING THE "IF'S" Formula.,A continuos flashing window with which title is C:Windows\System32\cmd.exe, and has the following message: The syntax of the command is incorrect.,Acrobat compatibility issue and you tube problems____,ActiveX on IE 9 not loaded

No comments:

Post a Comment