Send email based on selection in multi select lookup field

Send email based on selection in multi select lookup field

I want an email to be send to based on the selection of a multi select field.

I only want the email to be sent to the vendors that are selected in the multi select field that looks up from a vendor table.  The code im using is below but i cant get it to quite work. It seems to be sending an email to everyone in the vendor table rather than just to the people selected in the Vendors_in_RFQ  multi select field.

for each E in Vendor  [ID = input.Vendors_in_RFQ]
    {
        sendmail
        (
            To       :  E.Vendor_Email 
            From     :  "email@email.com" 
            Subject  :  "Subject"
            Message  :  "message"
        )
}


Thanks You
Matthew