Skip to main content

Posts

Showing posts from May, 2022

A Demo To Consume Azure Cosmos DB By .Net6 Web API

In this article, we will implement a .NET6 Web API that consumes the Azure Cosmos DB. Azure CosmosDB: Azure Cosmos DB is a fully managed NoSQL database. NoSQL says data will be stored as a key/value JSON document. Cosmos DB provides 'High Availability' and 'Low Latency' for any application. Cosmos DB is very quick in response delivering, auto-scaling, effective auto failure management, etc. Any existing application that works on different DBs can be easily migrated to Azure CosmosDB as it provides APIs for integration like 'SQL/Core API'(most recommended API, our demo uses this 'SQL/Core API'), 'MongoDB API', 'Cassandra API', 'Germlin API', 'Table API'. Let's understand the structure of the Cosmos DB: Create an Azure Cosmos Account with an appropriate subscription inside of the Azure portal. After creating the Cosmos Account, we can manage the data of our account by creating 'Database', 'Containers', an

Part-3 NestJS Email With File Attachment

In this article, we are going to implement NestJS sending emails with file attachments. Part-1 NestJS Send Plain Text Email Part-2 NestJS Send Dynamic Generated HTML Template As Email Install @types/nodemailer Package: Let's install the typescript nodemailer package. npm install --save-dev @types/nodemailer Endpoint To Send Email With File Attachment: Let's add a sample image file into the 'mail' folder that we are going to attach to the email. Let's create an endpoint to send the email with a file attachment. src/email.controller.cs: import { join } from 'path'; @Get('file-attachment') async fileAttachement(@Query('toemail') toemail){ var response = await this.mailService.sendMail({ to: toemail, from: 'nani.bommidi93@gmail.com', subject: 'File Attachment', html: "<h1>File Attachment</h1>", attachments:[{ path: join(__dirname,'mails','

Part-2 Generate Dynamic Email Template And Send Email In The NestJS Application

In this article, we are going to generate a dynamic data binding email template and then send emails from the NestJS application. Click here for part-1 Install Handlebar Package: Email body dynamic data binding can be achieved by using the 'Handlebar' libraries. npm install --save handlebars Register Handlebar Configuration: Let's register our handlebar template configuration into the 'MailerModule' in the 'AppModule'. src/app.module.ts: import { MailerModule } from '@nestjs-modules/mailer'; import { Module } from '@nestjs/common'; import { join } from 'path'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { EmailController } from './email.controller'; import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter'; @Module({ imports: [ MailerModule.forRoot({ transport: { host: 'smtp.send

Part-1 Email Sending In NestJS Application

In this article, we are going to understand email sending in the NestJS application. SMTP: Simple Mail Transfer Protocol(SMTP) is used to send, and receive emails in any application. So on an email sent, its transferred over the internet from one server to another using SMTP. For our demo, we are going to use the 'SendGrid' a third-party provider SMTP. SendGrid: To establish email communication in our NestJS application using SendGrid, then we need a few configurations from SendGrid like 'SMTP Host', 'from email address' 'user name', and 'password'. Step 1: Go to SendGrid's official website at 'https://sendgrid.com'. Next, do signup. Step 2: Now login into the SendGrid website, then under the left-hand side menu go to the 'Settings', then select 'Sender Authentication' menu. At 'Single Sender Verification' click on the 'Get Started' button. Step 3: Let's register the 'From Email Address'

A Demo On .NET6 API Sending Email Using SendGrid NuGet Package

In this article, we are going to implement a sample in .NET6 Web API to send emails using the SendGrid Nuget Package. Create A .Net6 Web API Project: Let's create a .Net6 Web API sample application to accomplish our demo. We can use either Visual Studio 2022 or Visual Studio Code(using .NET CLI commands) to create any.Net6 application. For this demo, I'm using the 'Visual Studio Code'(using the .NET CLI command) editor. CLI command dotnet new webapi -o Your_Project_Name SendGrid: SendGrid is a third-party email provider from which we can deal with 'send', and 'receive' operations of email to our application. SendGrid SMTP(Simple Mail Transfer Protocol) provider for email transfer. SendGrid also provides SendGrid .Net NuGet package that provides easy configuration to any .NET applications. So to use the SendGrid SMTP we need 'Auth Key', 'From Email', so let's register into the SendGrid. The following are the steps to register and