# Connect ZoomInfo contacts and Send email in our [serverless](/content/site-root.html) environment

Use this template to Get contacts from ZoomInfo API using them to send email messages.

### Get contacts from ZoomInfo API

#### Used integrations:

- [http](/content/docs/integrations/http/index.html)
-  JavaScript
-  Python

```js
class HttpSourceZoominfoContactSearch {
    async init() {
        this.httpClient = axios.create({
            baseURL: "https://api.zoominfo.com",
        });

this.jwtToken = await this.httpClient
            .post("authenticate", {
                username: yepcode.env.ZOOMINFO_USERNAME,
                password: yepcode.env.ZOOMINFO_PASSWORD,
            })
            .then((response) => response.data.jwt);
    }

async fetch(publish, done) {
        await this.httpClient
            .post(
                "search/contact", {
                    managementLevel: "directors",
                    companyType: "public",
                    zipCode: "19101",
                }, {
                    headers: {
                        Authorization: `Bearer ${this.jwtToken}`,
                    },
                }
            )
            .then(async ({ data }) => {
                for (const contact of data) {
                    await publish(contact);
                }
            });
        done();
    }

async close() {}
}
```

```py
import requests
from urllib.parse import urljoin

class HttpSourceZoominfoContactSearch:
    def setup(self):
        self.base_url = "https://api.zoominfo.com/"
        self.session = requests.Session()

response = self.session.post(
            "authenticate",
            json={
                "username": yepcode.env.ZOOMINFO_USERNAME,
                "password": yepcode.env.ZOOMINFO_PASSWORD,
            },
        )
        response.raise_for_status()
        self.jwt_token = response.json()["jwt"]

def generator(self):
        response = self.session.post(
            urljoin(self.base_url, "search/contacts"),
            json={
                "managementLevel": "directors",
                "companyType": "public",
                "zipCode": "19101",
            },
            headers={"Authorization": f"Bearer {self.jwt_token}"},
        )
        response.raise_for_status()
        contacts = response.json()
        for contact in contacts:
            yield contact

def close(self):
        pass
```

### Send email messages

#### Used integrations:

- [smtp](/content/docs/integrations/smtp/index.html)
-  JavaScript
-  Python

```js
class SmtpTargetSendEmail {
    async init() {
        this.smtp = nodemailer.createTransport({
            host: yepcode.env.SMTP_HOST,
            port: yepcode.env.SMTP_PORT,
            auth: {
                user: yepcode.env.SMTP_USER,
                pass: yepcode.env.SMTP_PASSWORD,
            },
        });
        this.items = [];
    }

async consume(item) {
        this.items.push(item);
    }

async close() {
        const text = `Here are the items we got:\n${this.items.map((item) => ` * ${item.id}: ${item.name}`).join("\n")}`;
        await this.smtp.sendMail({
            from: "your-email@example.com",
            to: "the-target@example.com",
            subject: `Choose your subject`,
            text,
        });
    }
}
```

```py
import smtplib

class SmtpTargetSendEmail:
    def setup(self):
        self.smtp = smtplib.SMTP(yepcode.env.SMTP_HOST, yepcode.env.SMTP_PORT)
        self.smtp.starttls()
        self.smtp.login(yepcode.env.SMTP_USER, yepcode.env.SMTP_PASSWORD)
        self.items = []

def consume(self, generator, done):
        for item in generator:
            self.items.append(item)
        done()

def close(self):
        text = "Subject: Mail subject\n\n"
        text += "Here are the items we got:\n"
        for item in self.items:
            text += f" * {item['id']}: {item['name']}\n"
        self.smtp.send_mail("your-email@example.com", "the-target@example.com", text)
```

### FAQs

#### What is YepCode?

YepCode is a SaaS platform that enables the creation, execution and monitoring of integrations and automations using source code in a serverless environment.

#### How these recipes may help me?

These recipes are an excellent starting point for creating your own YepCode processes and solving complex integration and automation problems.

#### How can I use YepCode?

You only have to complete the sign up form and your account will be created with our FREE plan (no credit card required).

#### Is YepCode just for single developers or may be used by enterprises?

YepCode has been created with a clear enterprise focus, offering a multi-tenant environment, team management capabilities, high security and auditing standards, Identity Provider (IdP) integrations, and on-premise options.
