3

I've a custom list and it has a people picker column 'A'. I want to send an email to the person in column 'A' if someone attaches a file to the list item. How can this be achieved without using SPD?

  • you want to achive your requirment without using SPD.M I right then you can use Event handler (C# code) – Akshay Dattatray Nangare Oct 18 '16 at 8:53
1

If you want to send email without using SPD, then there is another approach is Event Handler

  • Item Added event
  • Item Updated event

    public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);
        using (SPSite site = properties.OpenWeb().Site)
        {
            using (SPWeb web = properties.OpenWeb())
            {
    
    
            var attachments=properties.ListItem["Attachments"]
    
    #Check current item has attahments or not.If yes then send email
            if(attachments != null)
            {
            #write logic to send Email 
            }
        }
    }
    
    
    public override void ItemUpdated(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);
        using (SPSite site = properties.OpenWeb().Site)
        {
            using (SPWeb web = properties.OpenWeb())
            {
    
            var attachments=properties.ListItem["Attachments"]
            #Check current item has attahments or not.If yes then send email
            if(attachments != null)
            {
            #write logic to send Email 
            }
        }
    }
    
  • Is there any way to achieve this using javascript/jquery? – Korak Oct 18 '16 at 12:14
  • Yes, only when,If you have custom button to add/Update items in list. But if you are using default behavior of SharePoint list for add/update, then it is not possible using javascripts/jquery, in javascript you will not able to get the event item added/ item updated. I will suggest stick with the above suggest approach from answer – Akshay Dattatray Nangare Oct 18 '16 at 13:07
1

In SPD, you can create a new workflow on your list. Starting option will be on item updated (can be on item added too). Set a condition like : If current item : attachment file is yes, then send email to current item : column A : email.

You can also add in email body a link to current item : attachment file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.