+ Reply to Thread
Results 1 to 5 of 5

Excel vba to auto-send customer emails (duplicate emails issue)

  1. #1
    Registered User
    Join Date
    04-08-2014
    Location
    United Arab Emirates
    MS-Off Ver
    Excel 365
    Posts
    7

    Excel vba to auto-send customer emails (duplicate emails issue)

    Good day
    The code below generates a unique email + attachment to each line in column A based on other columns.
    This means if the same email exists more than once, they will receive more than one email with a unique attachment with each email.
    What I would like it to do is check whether the email exists in more than one line (already sorted) and send them one email only instead (with all the attachments). is this possible?
    this is my code:


    Dim objOutlook As Outlook.Application
    Dim objMail As Outlook.MailItem

    Dim rngTo As Range
    Dim rngSubject As Range
    Dim rngBody As Range
    Dim rngAttach As Range

    ActiveSheet.Range("A2").Select

    DoUntil IsEmpty(ActiveCell)

    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItemFromTemplate("C:\Desktop\EBILL\template.oft")

    With objMail
    .To= ActiveCell.Offset(0,4).Value
    .Subject ="Invoice For: "&" "& Month &" - "& Year
    .Attachments.Add ActiveCell.Offset(0,5).Value
    ActiveCell.Offset(1,0).Select
    .Display 'Instead of .Display, you can use .Send to send the email or .Save to save a copy in the drafts folder
    EndWith

    Loop


    Set objOutlook =Nothing
    Set objMail =Nothing
    Set rngTo =Nothing
    Set rngSubject =Nothing
    Set rngBody =Nothing
    Set rngAttach =Nothing

  2. #2
    Valued Forum Contributor
    Join Date
    11-12-2014
    Location
    Nottingham
    MS-Off Ver
    2013
    Posts
    383

    Re: Excel vba to auto-send customer emails (duplicate emails issue)

    In future make sure to put your code in code tags by pressing the # symbol!

    If they are already sorted then you may be able to do this, I'm unsure because you didnt attach a template workbook

    Please Login or Register  to view this content.
    !If all your troubles are solved, then so is the thread. Show this by marking it so using thread tools at the top of the page.
    If I helped do this, then please show your appreciation by awarding rep points.
    <------ Button for that is over there

  3. #3
    Registered User
    Join Date
    04-08-2014
    Location
    United Arab Emirates
    MS-Off Ver
    Excel 365
    Posts
    7
    Quote Originally Posted by ARowbot View Post
    In future make sure to put your code in code tags by pressing the # symbol!

    If they are already sorted then you may be able to do this, I'm unsure because you didnt attach a template workbook

    Please Login or Register  to view this content.


    Hi. Thank you so much for responding and apologies for the crappy formatting lol. I will try the code and if it doesnt work will attach my sheet for reference. Thanks once again for your kind help

  4. #4
    Registered User
    Join Date
    04-08-2014
    Location
    United Arab Emirates
    MS-Off Ver
    Excel 365
    Posts
    7

    Re: Excel vba to auto-send customer emails (duplicate emails issue)

    It works perfectly Thank you so much.
    Not sure why i hadn't thought of the same logic, very kind of you to help
    Have a good weekend !!

  5. #5
    Registered User
    Join Date
    04-08-2014
    Location
    United Arab Emirates
    MS-Off Ver
    Excel 365
    Posts
    7

    Re: Excel vba to auto-send customer emails (duplicate emails issue)

    It works perfectly Thank you so much.
    Not sure why i hadn't thought of the same logic, very kind of you to help
    Have a good weekend !!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Send Emails once expiry date is reached, and generate report based on emails sent
    By demonicscorpion in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2014, 05:36 AM
  2. [SOLVED] Macro To Send Emails with PDF: Multiple Emails and PDF's
    By totoga12 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-19-2014, 06:13 PM
  3. Send outlook emails with message in cells to individual emails associated with them
    By abinayan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2011, 06:11 AM
  4. 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
  5. Auto Send eMails From Excel Using My Menu
    By Launchnet in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2008, 02:19 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