How to send bulk SMS in excel using c#
Loading
How to send bulk SMS in excel using c#
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Oct 20, 2023, 8:12 AM EDT
To send bulk SMS in C# using an Excel file, you'll need to utilize any third-party SMS gateway API. Here's a basic example using the Twilio API for sending SMS (You can use any other api gateway according to your accessability). Make sure you have the Twilio package installed in your C# project. You can install it via NuGet package manager.
using System; using Twilio; using Twilio.Rest.Api.V2010.Account; using OfficeOpenXml; using System.IO; namespace BulkSMSSender { class Program { static void Main(string[] args) { const string accountSid = "YOUR_ACCOUNT_SID"; const string authToken = "YOUR_AUTH_TOKEN"; TwilioClient.Init(accountSid, authToken); var excelPackage = new ExcelPackage(new FileInfo("YOUR_EXCEL_FILE_PATH")); ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[0]; // Assuming data is in the first sheet int rowCount = worksheet.Dimension.Rows; for (int row = 2; row <= rowCount; row++) // Assuming the first row contains headers { string phoneNumber = worksheet.Cells[row, 1].Value?.ToString(); // Assuming phone numbers are in the first column string message = worksheet.Cells[row, 2].Value?.ToString(); // Assuming messages are in the second column var messageResource = MessageResource.Create( body: message, from: new Twilio.Types.PhoneNumber("YOUR_TWILIO_PHONE_NUMBER"), to: new Twilio.Types.PhoneNumber(phoneNumber) ); Console.WriteLine(messageResource.Sid); // You can handle the response here } } } }Make sure to replace the placeholders with your Twilio account SID, auth token, and phone number. Also, replace YOUR_EXCEL_FILE_PATH with the path to your Excel file. This script assumes the phone numbers are in the first column and the messages are in the second column of the Excel sheet.
Anandu G NathRank #681 · 3.5K reputationPosted Jan 8, 2024, 11:16 PM EST
@Thabang Mosaka
You have to purchase SMS API,
After that Load the data from excel to a datagridview , from datagridview you can send using foreach group.