Email sending program approach in C#? - c#

Imagine you're creating an email sending program using c# that send a "Welcome" email and a "Come back" email to your customers. The idea is that the application runs every day as a scheduled job. When the run it is printed if it went well or badly. How would you approach this? How would you think the architecture would look? And would you use any special techniques?

Use the MailMessage class to send emails.
Check it out here below:
https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.mailmessage?view=netframework-4.8
You can use either a console or a windows forms project for this. Keep the app open and use the DateTime class to loop through each day.
More about the DateTime class here:
https://www.c-sharpcorner.com/article/learn-about-datetime-in-c-sharp/
You can then use an MS SQL database to serve as your log for this application.

Not sure of you have heard about Hangfire, but I found it quite useful and easy to use to setup recurrent tasks like the one you described.
https://www.hangfire.io/

Related

Best practice to send a ASP.Net Core Web App project to someone?

I'm a newbie in ASP.NET projects and I am wondering how do I share my finished C# project to someone by email so they can run it (IIS Express) on their machine ? It's for a job offer skill test.
Do I need to send every files and folders or i can just send the source code?
The project folder is 6MB so i can't send it by email.
Sorry for my English and thanks for help !
A nice way to send it could be by uploading it to GitHub and sharing the repository link. Since it is for a job it will also showcase that you are Version Control savvy.
You can also include a README.md file there that describes the app.
I'm not sure this has anything to do with ASP.net. It's just a question on how to transfer a large file isn't it? If so, 6mb isn't really that large for email nowadays. Most mail servers will handle that fine. But if email is a problem, put it on one of the myriad of fileshare platforms available such as Dropbox.
As for what specific files you need to send. That would depend on the requirements the company gave you - but I'd imagine they certainly need to see your source code and likely want the entire thing to be runnable. So send whatever is needed so they can easily run it.
Have you tried zipping it up? Source code will generally zip very effectively to a much smaller file as it contains so much repetition.
Upload the zip file to your google drive and then send it as a drive attachment. (This is actually Google’s recommendation) Or just simply share it with them. I recommend that attachment be as small as possible in the event that the user your sending it to has a mail quota.

Best way to let multiple .NET apps communicate with each other

So, first of all sorry for my bad english.
Back to the questio, i have a main app, with a tab control, each tab contain another .NET exe. These need to send infos to the main app. Example:
Each exe in a tab have a random generated guid every second and the main app need to catch this and show in a listview or something as long the exe is "alive".
Currently i'm using SQLite, and everytime a new exe is started this one write in a table. Before closing it this exe remove the recod from the table.
In the mainwhile, the main app retrieve this update table and show the "alive" exe and the random generated guid (every second). All works fine, the problem is that i need to abandon this method and remove the two dll of SQLite.
What i tried is:
UDP socket between the N clients and the main app, but is not so stable. And sometime some exe got freezed. (using TCP will be so "heavy" for the only purpose to send a short string. Right?)
Changing the window text of the other exe and retrive it via processinfo, but is not updating it, i get it just the first time string.
So, there is a way for that? In local. Like, i don't know.. user32 sendmessage maybe? Or this method is too invasive for just a short string?
Considering that the N sub exe are process "inside" the main one, there is not a way to obtain infos from child process?
Thanks for your help!
UDP does not guarantee delivery of the packet by-desing. Unless you implement your own confirmation protocol above it. But implementation itself should be stable.
Using TCP will provide similar results. You'll just have to deal with reconnect stuff.
SendMessage/PostMessage is the easiest and straight forward method. But it will not allow you to pass string directly. Take a look at RegisterWindowMessage to register your own message and SendMessage with HWND_BROADCAST handle. And you'll have to send pointer to your string. Since SendMessage is synchronous you should be teoreticaly fine with disposing of that message, but I haven't tried that. Another option would be storing string somewhere-else (registry, file) and sending just update notification using SendMessage. And the main app will read and delete that registry/file record.
Self hosted WCF with netNamedPipeBinding should work as well. But that would be propably too robust solution.

How to make a system event application in c#?

I am trying to make the following. I have a class that at midmight it makes a log from what happened in a SQL table and makes an excel file of it. My issue is that I was told that it is inexcusable to have this application running all day only to have it run once a day and that I should do this with a system event, but I have no idea how to do this. Help, please?
The easiest solution is to use Windows' built in Scheduled Task support to run your app. Or, if you're using Microsoft Sql Server, a scheduled Sql Agent job.

Email scheduling in C# (ASP .NET)

Hi want to send birthday emails to all employees which details are stored in database.
I found Quartz .NET library
but can't understand the code exactly.
can anyone please give me some sample code.?
This is the first time I heard about Quartz. It looks cool.
Found this stackoveflow thread How to use Quartz.net with ASP.NET
Further to Ives - answer:
What about from their website:
http://www.quartz-scheduler.org/docs/examples/index.html
This blog maybe of help as well..
http://blog.goyello.com/2009/09/21/how-to-use-quartz-net-in-pro-way/
Stack Overflow Question
Sending Periodic Mail according to user's Setting in ASP.net?
I guess this is something similar here.
You can code a small console application, a simple database with 1 table as you said which keeps dates,names and other details you need.
Simply select all rows which meets condition
Birthday == DateTime.Now
and mail them in a loop.
You can add this exe as a scheduled job with a few clicks and set it to run every day. It would also be a good practice for you.
You can write a script file (possibly in VBScript as a VBS file) and schedule that script file in the Windows Task Scheduler (say every morning 8 AM) on the server level.

Spell check in winforms

In my win forms C# app, I want to be able to add spell check functionality. But, I want to do it my own way, and NOT use any other components. All I need is just an online service where I can send a request or something and it tells me whether or not the word i sent was spelled correctly.
Preferred but not required: The ability for that online service to also send back suggestions.
Personally, I wonder why you want only online access...what if you lose connection? Also, most online accesses come with restrictions.. which you might hit sooner than you think during debugging.
If you were to use WPF, I'd suggest using the SpellCheck Class.
Since you specified Windows.Forms, you might try the NetSpell library for offline access. You can also try and use Microsoft Word's spellchecker, but you might not have it installed on the machine (or use Linux & Mono)
If you persist on using online access, you can use Yahoo, as Giovanni Galbo says. It's been done in C# before.
A quick google search turned up this:
Search Web Services: Spelling Suggestion
This is not c#/.NET specific. Its a simple REST service provided by Yahoo!. It looks like they do limit you to 5,000 queries per day for free and I'm not sure if Yahoo! lets you upgrade to a pay service.

Categories

Resources