+ Reply to Thread
Results 1 to 15 of 15

If Next Row is the Same Recipient, Attached the next file to the Mailitem

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Hello,

    Please Help!

    I have a working script below, it works on a 1 attachment and 1 recipient email only.

    My problem is, if the next Row is the same recipient, it should attached the next file and add the name on the subject.

    -Ln is the File Name too.

    Capture.JPG


    Please Login or Register  to view this content.
    Big thanks!

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,771

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    First arrive the Concatenated Subject based on the email id and get the attachments in separate columns. if the columns are empty then you can skip the attachments.

    Instead of correcting the the email VBA code, just correct your data structure then apply the your email code. That is the easy and right way of approach.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    This will give you a basic idea how it might work. It's based on your example picture.
    Otherwise we'll need a example file to adapt it to your needs.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Hello bakerman2

    I can't understand your script. It's too difficult for me.

    Please find my attachment for your reference.

    I hope my attachment suffice all what are needed.

    Thank you very much!
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    hello,

    The code works!

    But I'm stuck in the error handling situation.

    I need to put the result in the third column.

    for example:
    cells (x, 3) = "Sent"

    and also,

    Subject should be with "and" in the last combination
    Apple, Mango and Banana

    Please help.

    Please Login or Register  to view this content.
    Big Thanks,

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    How about this ?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Hello Bakerman2,

    thank you for helping.

    Error on Recipient is not working. Still returning "Sent".

    and also,

    if attachment not found, the rest of the items with the same recipient should be returned as "Sending Cancelled".

    Capture 2.JPG

    Big Thanks!

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Try this
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Not working.

    Capture 3.JPG

    It supposed to be "Sending Cancelled" bcos it did not send.

    Thank you,

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Works just fine for me.

    sunjam.PNG

  11. #11
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Because in your example, the others with the same recipient did not really found the attachment.

    If the others found the attachment, it returns as "Sent".

    if one is "attachment not found", the rest should be "sending cancelled".

    thanks,

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    This works as intended.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    Hello Bakerman2,

    It works! But there is a flaw.

    If the "Attachment not found", the next same recipient will return as "Sending Cancelled" but the previous same recipient still mark as Sent

    Capture 4 .JPG

    Capture 5.JPG

    Big Thanks,

  14. #14
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    I'm sorry but we're already way past the scope of your original question.
    You keep adding new parameters and changing conditions so so code needs to be revised every time.
    I don't have the time to keep adapting and searching solutions so I'm sorry but it stops here for me.
    Good luck with your project.

  15. #15
    Registered User
    Join Date
    02-19-2013
    Location
    Cebu, Philippines
    MS-Off Ver
    Excel 2010
    Posts
    88

    Re: If Next Row is the Same Recipient, Attached the next file to the Mailitem

    I understand.

    Thank you for your help. very much appreciated!

+ 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. [SOLVED] Loop through files in folder, email file to listed recipient of file name = cell value
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2017, 03:41 PM
  2. Sending the Excel file to multiple recipient in outlook application by using macro
    By vigneshwaran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2012, 10:31 AM
  3. Sending the Excel file to multiple recipient in outlook application using macro script
    By vigneshwaran in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-19-2012, 03:55 AM
  4. Send file to mail recipient doesn't work
    By pluginguin in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 01-17-2012, 05:59 AM
  5. MailItem.Show
    By RichardBerry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2007, 06:15 AM
  6. Replies: 4
    Last Post: 02-11-2005, 03:06 PM

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