{"id":19991618,"url":"https://github.com/EdiWang/Edi.TemplateEmail","last_synced_at":"2025-05-04T10:32:06.320Z","repository":{"id":14559462,"uuid":"17275170","full_name":"EdiWang/Edi.TemplateEmail","owner":"EdiWang","description":"Configure content template in xml and send email","archived":false,"fork":false,"pushed_at":"2024-03-04T04:22:39.000Z","size":595,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-04T05:30:24.284Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EdiWang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2014-02-28T04:30:42.000Z","updated_at":"2024-04-15T06:08:40.788Z","dependencies_parsed_at":"2024-03-04T05:28:48.020Z","dependency_job_id":"9b242192-2c94-466a-bd66-f0df8cf081fa","html_url":"https://github.com/EdiWang/Edi.TemplateEmail","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdiWang%2FEdi.TemplateEmail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdiWang%2FEdi.TemplateEmail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdiWang%2FEdi.TemplateEmail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EdiWang%2FEdi.TemplateEmail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EdiWang","download_url":"https://codeload.github.com/EdiWang/Edi.TemplateEmail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252320514,"owners_count":21729142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:51:50.440Z","updated_at":"2025-05-04T10:32:06.314Z","avatar_url":"https://github.com/EdiWang.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"Edi.TemplateEmail\n===============================\n\nThis library enable you to configure email in XML template and send the email in your .NET applications.\n\n\u003e Currently, only SMTP Basic Authentication is supported.\n\n[![NuGet][main-nuget-badge]][main-nuget]\n\n[main-nuget]: https://www.nuget.org/packages/Edi.TemplateEmail/\n[main-nuget-badge]: https://img.shields.io/nuget/v/Edi.TemplateEmail.svg?style=flat-square\u0026label=nuget\n\n## Install\n\n```\ndotnet add package Edi.TemplateEmail\n```\n\n## Usage\n\n\n### Step 1: Put a mailConfiguration.xml somewhere you like\n\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003cMailConfiguration\u003e\n  \u003cCommonConfiguration OverrideToAddress=\"false\" ToAddress=\"overridetest@test.com\" /\u003e\n  \u003cMailMessage MessageType=\"TestMail\" IsHtml=\"true\"\u003e\n    \u003cMessageSubject\u003eTest Mail on {MachineName.Value}\u003c/MessageSubject\u003e\n    \u003cMessageBody\u003e\n      \u003c![CDATA[\nMail configuration on {MachineName.Value} is good: \u003cbr /\u003e\nSmtp Server: {SmtpServer.Value}\u003cbr /\u003e\nSmtp Port: {SmtpServerPort.Value}\u003cbr /\u003e\nSmtp Username: {SmtpUserName.Value}\u003cbr /\u003e\nEmail Display Name: {EmailDisplayName.Value}\u003cbr /\u003e\nEnable SSL: {EnableSsl.Value}\u003cbr /\u003e\n      ]]\u003e\n    \u003c/MessageBody\u003e\n  \u003c/MailMessage\u003e\n\u003c/MailConfiguration\u003e\n```\n\n### Step 2:\n\nInitialize the `EmailHelper` by your mail server settings\n\n```\n// Change these values\nvar smtpServer = \"smtp.example.com\";\nvar userName = \"test1@example.com\";\nvar password = \"********\";\nvar port = 25;\nvar toAddress = \"test2@test.com\";\n\nvar configSource = $\"{Directory.GetCurrentDirectory()}\\\\mailConfiguration.xml\";\nvar emailHelper = new EmailHelper(configSource, new(smtpServer, userName, password, port)\n{\n    SenderName = senderName,\n    EmailDisplayName = displayName\n});\n```\n\n### Step 3: Map the values and send Email\n\n```\nvar message = emailHelper.ForType(\"TestMail\")\n    .Map(\"MachineName\", Environment.MachineName)\n    .Map(\"SmtpServer\", emailHelper.Settings.SmtpServer)\n    .Map(\"SmtpServerPort\", emailHelper.Settings.SmtpServerPort)\n    .Map(\"SmtpUserName\", emailHelper.Settings.SmtpUserName)\n    .Map(\"EmailDisplayName\", emailHelper.Settings.EmailDisplayName)\n    .Map(\"EnableTls\", emailHelper.Settings.EnableTls)\n    .BuildMessage([toAddress]);\n\nvar result = await message.SendAsync();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEdiWang%2FEdi.TemplateEmail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEdiWang%2FEdi.TemplateEmail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEdiWang%2FEdi.TemplateEmail/lists"}