One of the easiest and most useful ways to send your image chart is via email transfer. Email marketing is a crucial component of many small and large businesses. It allows business professionals to send statistical information and interpreted data to stakeholders in a very effective manner to connect with them on a personal level.
Most emails consist of a body of text and attachments. Sending charts as attachments restricts the receiver from interpreting it entirely. Sending image charts via email in the form of a URL string helps in the following ways:
- It generates clickable icons for the email recipient
- It can be accompanied by an analysis of the statistical information
- It is visually pleasing
- It can be customized (unlike sending charts as attachments)
However, exporting chart image in email is something that not a lot of people are familiar with. It requires using programming languages like JavaScript, PHP and C++. Therefore, we have put together this simple and straightforward guide that can help you in sending image charts through email.
If you want to know how to embed image charts in your email, refer to the guide on our website available here.
So, let’s begin.
The Benefits of Exporting Chart Image in Email
There are numerous advantages of sending image charts through email to the interested recipients that require the information. Here are some ways in which you can make your email communication beneficial by sending chart images:
- Increase number of subscribers
- Send personalized/customized image charts
- Present statistical data to email recipients in a visually appealing form
- Represent the standing of your business
The 5 Step Process of Exporting Chart Image in Email
In this section, we will take you through a 5-step process of exporting chart image in email and discuss some useful tips that we have collected to better guide your research.
Step # 1: Creating the URL String for your Image Chart
Using an image chart tool, like Image-Charts, you must first create a URL string for your image chart. The URL string must have:
- A base URL. For example: https://image-charts.com/chart
- Add parameters like:
- Chart type (bar graph, line graph, pie chart etc.)
- Width (of the chart image)
- Height (of the chart image)
- Pixel ratio (of the chart image)
- Labels
- Axes
- Add <img> tag at the end of your URL to embed it into an email
USEFUL TIP: For more complex charts like pie charts, you also need to define parameters like “background color.”
Step # 2: Exporting Chart to Image
The next step is to convert your chart into an image. Image-Charts provides a built in option to export data into the source box. Charts can be exported into common formats like:
- JPEG
- CSV
- SVG
- XLSX
- PNG
- JSON
USEFUL TIP: Choose a format that is most preferred by your email recipients and easily understandable by them. For example, a finished goods manufacturer will most likely communicate using JPEG or PNG formats.
Step # 3: Choosing Between Different Programming Languages
The third step is to decide which programming language you will convert your chart configuration in before exporting chart image in email.
Consider you created a chart configuration for a simple line graph chart:
chart_config = {
'type': 'line',
'data': {
'labels': ['Year 1', 'Year 2', 'Year 3', 'Year 4'],
'datasets': [{
'label': 'Profits',
'data': [12, 5, 40, 5]
}, {
'label': 'Sales',
'data': [80, 42, 215, 30]
}]
}
}))
You must decide which programming language you want to convert your configuration in. Let’s suppose you choose JSON. Your configuration will look something like this:
import json
from urllib.parse import quote
encoded_config = quote(json.dumps(chart_config))
chart_url = f'https://image-charts.com/chart.js/2.8.0?c={encoded_config}'
Step # 4: Adding the Email Message to the Converted Configuration
The 4th step is to add an email message to your configuration that will be sent along with your image chart. Add any message you want to send to the email recipient. The end result will be displayed in the following way:
import json
from urllib.parse import quote
encoded_config = quote(json.dumps(chart_config))
chart_url = f'https://image-charts.com/chart.js/2.8.0?c={encoded_config}'
email_message = f"""Hello, this email body contains a chart image about our yearly sales and profits for your reference. Please see the chart below:
<br><br>
<img src="{chart_url}" />
"""
Step # 5: Emailing Your Configuration Using a Service Provider
The last step is to send your configuration with the email message using any email service provided like Gmail or Outlook. Let’s suppose you are using Gmail. Your encoded configuration will look like this:
import requests
request_url = f'https://mail.google.com /v2/{DOMAIN}/messages'
request = requests.post(request_url, auth=('api', 'your_api_key_here'), data={
'from': 'myemail@gmail.com',
'to': 'toemail@xyz.com',
'subject': 'Updated Sales and Profits Chart Report with Gmail',
'html': email_message,
})
print(f'Status: {request.status_code}')
print(f'Body: {request.text}')
And you are done!
Your image chart will be exported along with your email message to the recipient.
Conclusion
We hope you liked our 5-step tutorial on exporting chart images in email. Visit our website and test our exporting tool today to export your chart image in email.
Comment below if you have questions about exporting chart images in email or if you want to share your experiences with us. To get notifications or updates on our services, visit our webpage by clicking here.