Email based on Criteria ....

  • 1)

    Set f = ws2.Columns("E").Find(ws.Cells(c.Row, "H"), ws2.[E1])

    a. If it was already processed, the log sheet knows it. Why would you want to send it again? You may need change this but maybe the formula for c would be sufficient.

    If c < 95 Or c > 100 Then GoTo NextC 'Not due yet so skip.

    b. Yes, but there are lots of considerations. e.g. Were all entries processed?
    (1) What if you delete Data rows? Just change the unique column formula. e.g. All Data rows deleted. The first formula would be to add the last unique number to Row() in the formula. Doing it this way, your log sheet would likely never need to be changed until you get to the last row...

    3) Do it like I did the .To but use .CC. Multiple CC's or TO's can be done just like you do in Outlook. It can be a Group that exists in the user's Outlook AddressBook or semi-colon delimited. e.g. [email protected];[email protected].
    You may need to do an IF to make sure that the value for CC <> "".

    4) You said that you wanted one user. If you want ALL then delete the username IF. If you want limited users, say your username at work and username at home or others then add OR's. If you have many but still limited, a Select Case might be more best. My rule for such is usually 4 or more.

    If user <> "PrakashPC" or user <> "ken" Then Exit Sub
  • sir after f8 on each line ..its showing at this place , Run-time error 462 said the remote server machine doesn't exist or unavailable . Even my outlook is also open

          Set Word = .GetInspector.WordEditor
          Set wr = Word.Content
          wr = body

  • Hello Sir,
    Hope you are doing great , sir everything is working perfect but the only this is with the below code because as my file is in network drive and every computer has different version of outlook sometime getting error in some computers , Compile error in hidden module .
    is it possible to remove outlook version limitations??? and also do I have to do tools>reference>object library for every computer???

    Thank you

    Sub EmailByDateDue2()
      Dim ws As Worksheet, ws2 As Worksheet, r As Range, c As Range
      Dim u$, d$
      Dim f As Range, sig$, SentOnBehalfOfName$, body$, user$
      'Tools > References > Microsoft Outlook xx.0 Object Library
      Dim olApp As Outlook.Application, olMail As Outlook.MailItem
      'Tools > References > Microsoft Word xx.0 Object Library
      Dim Word As Document, wr As Word.Range
  • While there are ways to set references for the user, late binding is the way most get around those issues. Some will code in early binding and then make the production version using late binding. To do that, one needs to: (1) change Dim variable types to Object, (2) Change Set lines, and (2) change constant variables to their values.


  • Sir after running the code I just got this error. I changed ------

    [SIZE=13px]Dim variable types to Object------Change Set lines-----change constant variables to their values.

    I also Unchecked it from[/SIZE]

    [SIZE=12px]Tools > References > Microsoft Outlook xx.0 Object Library
    Tools > References > Microsoft Word xx.0 Object Library[/SIZE]

    or Do I Have to keep it Checked in one system..

  • Post the code or workbook so I can check.

    Good morning sir,
    Thank you for your frequent replies. Please find the attachment I changed the below line while getting the errors and few columns.

    Set olApp = GetObject(, "Outlook.Application") 'Late binding

    Set olApp = CreateObject("Outlook.Applicaiton") 'Late binding


    one quick question sir ,

    If i want the entry should write from row 5 of column A , then where i have to make changes ... i tried like this but it didn’t work for me .

    Set f = ws2.Columns("A").Find(ws.Cells(c.Row, "A"), ws2.[A5])

    Set f = ws2.Cells(Rows.Count, "A").End(xlUp).Offset(1)

  • yes, your are right sir, Active X components error 429 is occurring in both codes. when outlook is closed, Sometimes error of Automation and Hidden Modules error in other PC's. Either its Getobject() or CreateObject().

  • The error 432 in post #34 was likely due to the sig file not existing. I thought that I had showed you how to check for that and skip it. Here I show you how to abort the macro if it does not exist.

    The getUserName is likely an API which was not in the file in post #34.

    After I changed your Column I to Column G for the "100 day" check, it worked fine.

  • [SIZE=13px]


    Hello sir,

    I just got an error, Everything is working fine when outlook is open.

    1) but at the time with closed outlook .. error of automation “disconnected from client “ error is coming when uncommenting (" “.send "” )with closed outlook.......//////

    When (" '“ ‘.send is for only comment “") with outlook closed then its fine ...


    2) sometimes also getting an error of outlook contact library.

    Please assist. Thank you ..

  • Those are two separate issues that any Outlook macro might see. They could have been asked in two separate threads/topics.

    1. Is easily solved by leaving Outlook open.
    a. I doubt that I would see that error. The usual problem is that the sent Emails are only sent from OutBox when Outlook opens. You can test if Outlook is open and open to avoid that issue.

    2. I am guessing that rather than an Email address with the @ character, you have used an Alias which is a group. If it does not exist in your Contact addressbook, then it errors. To Resolve that, one would use well, Resolve. e.g.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!