+ Reply to Thread
Results 1 to 14 of 14

Find totals and send emails to different people

  1. #1
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Find totals and send emails to different people

    Hi Friends / Geniuses / Observers

    Wondering if you can help me to create a macro to send emails.

    1. Attached is an excel spreadsheet. In column A, each time the word total is seen, i want an email to be sent to to someone with the total in colum E.

    Eg.
    A B C D E
    UAFEQ1 TOTAL xxxx xxxxxxxx xxx R 15 000
    ALPROP TOTAL xxxx xxxxxxxxx xxx -R 20 000

    For UAFEQ1 TOTAL I would like a mail to be sent to john@example.com
    For ALRPOP TOTAL I want like a mail to be sent to peter@example.com

    If the total in column E is positive i want the mail to say:
    Please see deposit of R 15 000

    If the total in colum E is negative i want the mail to say:
    Please see withdrawal of -R 20 000

    The currency is Rands (South Africa)

    Sometimes, i need to send 20 or more e-mails. And these can repeat themselves so, there may be two totals for UAFEQ1 TOTAL and a mail must be sent each time. See attached as an example.

    The macro can stop when Grand Total is reached. No email needs to be sent for the grand total.

    Thanks a million for you help!!

    Regards
    Dean
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-03-2008
    Location
    Hyderabad, India
    MS-Off Ver
    2003 and 2007
    Posts
    58

    Re: Find totals and send emails to different people

    Hi,

    Refer this link,
    http://www.rondebruin.nl/cdo.htm
    Salim

  3. #3
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Thanks Salim, as helpful as this doc is, truthfully, my VBA skills are way to poor to understand most of it...I am trying though.

    Do you, or does anyone have any code which is more specific to my issue which I can copy and past into the module screen?

    Dean (Nonboff)

  4. #4
    Registered User
    Join Date
    07-03-2008
    Location
    Hyderabad, India
    MS-Off Ver
    2003 and 2007
    Posts
    58

    Re: Find totals and send emails to different people

    Hi,

    I try the code for your requirement.
    Place this code in one module.
    Call this method from your worksheet using button.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Hi Salim

    Thanks for quick reply.

    The macro returned a run-time error '9' subscript out of range at the following piece of code:
    Set wsMain = ThisWorkbook.Worksheets("CASHFLOWS UTS")
    The Worksheet is called CASHFLOWS UTS

    You have in the code assumes level 3 (does this mean only 3 emails - because this spreadsheet has up to say 50emails sometimes).

  6. #6
    Registered User
    Join Date
    07-03-2008
    Location
    Hyderabad, India
    MS-Off Ver
    2003 and 2007
    Posts
    58

    Re: Find totals and send emails to different people

    Hi,
    Change the code, and make the comment in show level.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Hi again

    The earlier problem is now solved. The macro returned a run-time error '9' subscript out of range at the following piece of code:
    Set wsMain = ThisWorkbook.Worksheets("CASHFLOWS UTS")
    The Worksheet is called CASHFLOWS UTS


    You have in the code assumes level 3 (does this mean only 3 emails - because this spreadsheet has up to say 50emails sometimes).

    I guess i have to unqote the following and have to put SMTP server details in. For Outlook express where to i get the SMTP server details?

    ' iConf.Load -1 ' CDO Source Defaults
    ' Set Flds = iConf.Fields
    ' With Flds
    ' .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    ' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
    ' = "Fill in your SMTP server here"
    ' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    ' .Update
    ' End With

  8. #8
    Registered User
    Join Date
    07-03-2008
    Location
    Hyderabad, India
    MS-Off Ver
    2003 and 2007
    Posts
    58

    Re: Find totals and send emails to different people

    Okey remove Comment that lines also,
    Please Login or Register  to view this content.
    Get the smtp sereve details from outlook:
    Tools - Account Settings -
    (Click change ur existing account - u can view the all details about that account)

  9. #9
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Unbelievably, this worked! I used my gmail account to send mail to my hotmail account and it worked.

    Just a couple questions. After the main body (.TextBody = strbody) the value is added. How do i add a signature such as follows after the text?
    Thank you
    Dean

    I will try this from work on Monday using my outlook....

    Regards
    Dean

  10. #10
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Hi Salim / All

    I've tried working with this, but the trouble I am having is that in I have a long list of people I need to e-mail. The list is going to change regularly, so i will need to save details either on a spreadsheet or in a folder (preferably a folder). So instead, I am wondering if I can change this up a little.

    A new spreadsheet is attached.

    I simply want to email each person (fund) in colum A with the value in column D. If the value in colum D is positive, then say deposit. If negative we say, withdrawal.

    Email address details are on tab called Email details.

    An example of finished product would be as follows:
    .......................................................................................................
    To:Focused.Fund@example.com
    Subject: Focused Equity Fund Class B1

    Important Notification

    Please note the following deposit into you account: R 15 000

    Kind regards
    Dean
    .......................................................................................................

    So, somehow we need to use a vlookup from tab1 to tab2 (althought i would prefer it, if tab2 to were located on a file on my pc say D:\Documents and Settings\Legend\Desktop\
    Rondebruin is a legend and I did get the above code to work. I've nearly managed to get the signature added.

    If someone could whip up this code for me, i would be hugely grateful!!

    Many thanks
    Dean
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Anybody had any luck with this? Maybe today will be the day!!
    Dean

  12. #12
    Registered User
    Join Date
    07-03-2008
    Location
    Hyderabad, India
    MS-Off Ver
    2003 and 2007
    Posts
    58

    Re: Find totals and send emails to different people

    Hi,

    Add this code to include in your code before for loop.

    Please Login or Register  to view this content.
    And also you remove the "TextBody".
    You use "HtmlBody" for this.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    Hi Salim

    I have made the adjustments required but it is falling over at point indicated below:

    Please Login or Register  to view this content.
    Any ideas?

    Are you by any chance able to do the loop mentioned in my previous post above, where names in column 1 are emailed the value in column D (email addresses saved on either tab2 or in a file saved in a folder?

    Dean

  14. #14
    Registered User
    Join Date
    04-01-2009
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Find totals and send emails to different people

    I'm getting desperate to get this loop sorted. Maybe I should close this post and start afresh. Is this allowed?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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