SmartCheck Integration with Outlook
Certify your Outlook emails directly from the server using SmartCheck
SmartCheck is a feature of Code Contract that allows you to generate unique, secure, and tamper-proof digital evidence in just seconds and at an affordable cost.
One of its most common applications is email certification. Below is a step-by-step guide on how to certify Outlook emails using SmartCheck and Microsoft services:
Step 1: Obtain the Authentication Token
To use the SmartCheck API, you must first authenticate via a POST request to obtain a JWT Token.
Authentication Request (HTTP Request)
POST /login HTTP/1.1
Host: api.codecontract.io
Content-Type: application/json
{
"email": "[email protected]",
"password": "your_password"
}
Expected Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Important:
✔️ The returned token must be stored and included in every subsequent request as a Bearer Token in the Authorization header.
✔️ If Outlook uses OAuth for authentication, you must first obtain an OAuth token and send it to SmartCheck.
Step 2: Certify Outlook Emails with SmartCheck
Once authenticated, you can send the email content to SmartCheck to certify it on the blockchain.
Example: Certify an Outlook Email
Use the Microsoft Graph API to retrieve the content of the email and send it to SmartCheck.
1️⃣ Retrieve the Email using Microsoft Graph API (Python Example)
import requests
def get_outlook_email(access_token, email_id):
""" Retrieves an Outlook email by its ID """
url = f"https://graph.microsoft.com/v1.0/me/messages/{email_id}"
headers = {
"Authorization": f"Bearer {access_token}",
"Accept": "application/json"
}
response = requests.get(url, headers=headers)
email_data = response.json()
return email_data.get("body", {}).get("content", "")
# Replace with a valid Microsoft Graph access token and email ID
access_token = "YOUR_OUTLOOK_ACCESS_TOKEN"
email_id = "EMAIL_ID"
email_content = get_outlook_email(access_token, email_id)
print("Retrieved email content:", email_content)
2️⃣ Send the Email Content to SmartCheck for Certification
def certify_email(email_content):
""" Sends the email content to SmartCheck for certification """
url = "https://api.codecontract.io/smartcheck/createTreeAndRegisterMerkleRoot"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"data": [email_content]
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
# Certify the retrieved email
certification_response = certify_email(email_content)
print("Certification response:", certification_response)
Expected Response
{
"merkleRoot": "abc123...",
"transactionId": "tx123...",
"status": "success"
}
What does this mean?
✔️ merkleRoot: Merkle root generated from the email content.
✔️ transactionId: ID of the blockchain transaction.
✔️ status: Indicates whether the certification was successful.
Step 3: Verify a Certified Email
If you need to check whether an email has already been certified, you can query the proof in SmartCheck.
Request to Retrieve Certification Details
GET /smartcheck/reportsProofDetail?reportId=your_report_id HTTP/1.1
Host: api.codecontract.io
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
Expected Response
{
"reportId": "your_report_id",
"merkleRoot": "abc123...",
"data": [
"certified email"
],
"status": "verified"
}
Summary
✔️ Step 1: Obtain the JWT Token by authenticating with your Outlook account.
✔️ Step 2: Use Microsoft Graph API to retrieve the email content.
✔️ Step 3: Send the content to SmartCheck for blockchain certification.
✔️ Step 4: Verify the certification as needed.
If you need more information or support, feel free to contact the Code Contract team. 🚀
