Home > other >  Is there anyway to send email to a list of contact?
Is there anyway to send email to a list of contact?

Time:03-14

Is there anyway to send email to a list of contact? I can't find any api docs about this.

CodePudding user response:

When sending an email with SendGrid you can send to one or multiple email addresses, and you can do so via the to, cc, and/or bcc fields.

When you send an email via SendGrid, you do so using "personalizations". According to the documentation, personalizations are:

An array of messages and their metadata. Each object within personalizations can be thought of as an envelope - it defines who should receive an individual message and how that message should be handled.

An example of an array of personalizations might look like this:

[
    {
      to: [
        {
          email: '[email protected]',
          name: 'John Doe'
        },
        {
          email: '[email protected]',
          name: 'Julia Doe'
        }
      ],
      cc: [
        {
          email: '[email protected]',
          name: 'Jane Doe'
        }
      ],
      bcc: [
        {
          email: '[email protected]',
          name: 'Jim Doe'
        }
      ]
    },
    {
      from: {
        email: '[email protected]',
        name: 'Example Sales Team'
      },
      to: [
        {
          email: '[email protected]',
          name: 'Janice Doe'
        }
      ],
      bcc: [
        {
          email: '[email protected]',
          name: 'Jordan Doe'
        }
      ]
    }
  ]

In the above example, one email is sent to two different people, John Doe and Julia Doe, cc'd to Jane Doe and bcc'd to Jim Doe. An email with the same content is also sent from a different email address ([email protected]) to Janice Doe and bcc'd to Jordan Doe.

Hopefully you can see that specifying the recipients of an email is very flexible and you can send to many people at the same time.

Check out the documentation and code examples for sending emails with SendGrid for more information.

  • Related