Click here to Skip to main content
15,868,033 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: c# forms (holy crap i'm not ready for this) Pin
Uranium-23511-Apr-20 16:33
Uranium-23511-Apr-20 16:33 
QuestionEntity Framework Code First is generating an extra column - need some help please Pin
simpledeveloper9-Mar-20 9:44
simpledeveloper9-Mar-20 9:44 
AnswerRe: Entity Framework Code First is generating an extra column - need some help please Pin
Uranium-2359-Mar-20 14:13
Uranium-2359-Mar-20 14:13 
AnswerRe: Entity Framework Code First is generating an extra column - need some help please Pin
Richard Deeming10-Mar-20 0:55
mveRichard Deeming10-Mar-20 0:55 
QuestionBest way to remotely send/retrieve data (securely) Pin
Uranium-2357-Mar-20 15:03
Uranium-2357-Mar-20 15:03 
AnswerRe: Best way to remotely send/retrieve data (securely) Pin
Gerry Schmitz8-Mar-20 10:05
mveGerry Schmitz8-Mar-20 10:05 
GeneralRe: Best way to remotely send/retrieve data (securely) Pin
Uranium-2358-Mar-20 19:41
Uranium-2358-Mar-20 19:41 
QuestionSending email via .net core 3 using Worker Service Pin
ElenaRez25-Feb-20 4:00
ElenaRez25-Feb-20 4:00 
Hi. I want to implement a sending email service using .net core worker service. For doing that I use .net core 3 Worker service and in Worker class and I added NetCore.MailKit 2.0.2 to my project. I added the below lines of code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Mail;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
using MimeKit;
using MimeKit.Text;

namespace MyWorkerService
{
public class Worker : BackgroundService
{
private readonly ILogger<worker> _logger;
private HttpClient client;
public Worker(ILogger<worker> logger)
{
_logger = logger;
}

public override async Task StartAsync(CancellationToken cancellationToken)
{

var message = new MimeMessage();
message.To.Add(new MailboxAddress("Mike", "mike@gmail.com"));
message.From.Add(new MailboxAddress("Elen", "elen@gmail.com"));
message.Subject = "Hi";
message.Body = new TextPart(TextFormat.Html)
{
Text = "Email for testing"
};
//-----------------------------------------------------------

using (var client = new MailKit.Net.Smtp.SmtpClient())
{

client.Connect("smtp.gmail.com", 587, false);

//SMTP server authentication if needed
client.Authenticate("elen@gmail.com", "fava");

client.Send(message);

client.Disconnect(true);
}

}

public override async Task StopAsync(CancellationToken cancellationToken)
{
// DO YOUR STUFF HERE
await base.StopAsync(cancellationToken);
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
await Task.Delay(1000, stoppingToken);
}
}
}
}

And the program class is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace MyWorkerService
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseWindowsService()
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<worker>();
});
}
}
I could created and deployed the service and when I start it, its status changes to running. Now my problem is, it doesn't send any email to the specified email address. I appreciate if anyone could solve my issue.
AnswerRe: Sending email via .net core 3 using Worker Service Pin
ZurdoDev25-Feb-20 4:25
professionalZurdoDev25-Feb-20 4:25 
SuggestionRe: Sending email via .net core 3 using Worker Service Pin
Richard MacCutchan25-Feb-20 4:27
mveRichard MacCutchan25-Feb-20 4:27 
SuggestionRe: Sending email via .net core 3 using Worker Service Pin
Richard Deeming25-Feb-20 4:55
mveRichard Deeming25-Feb-20 4:55 
QuestionProblems with EntityFramwork - compatible Framework Database Driver not found?! Pin
ricardo188515-Feb-20 9:33
ricardo188515-Feb-20 9:33 
AnswerRe: Problems with EntityFramwork - compatible Framework Database Driver not found?! Pin
Gerry Schmitz15-Feb-20 9:52
mveGerry Schmitz15-Feb-20 9:52 
QuestionClosing and Disposing Excel Application Process in C# Pin
Pramod_Kumar14-Feb-20 4:26
Pramod_Kumar14-Feb-20 4:26 
AnswerRe: Closing and Disposing Excel Application Process in C# Pin
Richard Deeming4-Feb-20 4:37
mveRichard Deeming4-Feb-20 4:37 
Questionconverting text file data from string to X,Y,Z coordinates Pin
Sher Shah 11-Feb-20 3:32
Sher Shah 11-Feb-20 3:32 
AnswerRe: converting text file data from string to X,Y,Z coordinates Pin
Pete O'Hanlon1-Feb-20 4:10
subeditorPete O'Hanlon1-Feb-20 4:10 
GeneralRe: converting text file data from string to X,Y,Z coordinates Pin
Sher Shah 11-Feb-20 5:11
Sher Shah 11-Feb-20 5:11 
GeneralRe: converting text file data from string to X,Y,Z coordinates Pin
phil.o1-Feb-20 6:28
professionalphil.o1-Feb-20 6:28 
QuestionApplication wide information into classes in referenced DLL's Pin
A D Rosser28-Jan-20 4:22
A D Rosser28-Jan-20 4:22 
AnswerRe: Application wide information into classes in referenced DLL's Pin
Richard Deeming28-Jan-20 4:32
mveRichard Deeming28-Jan-20 4:32 
GeneralRe: Application wide information into classes in referenced DLL's Pin
A D Rosser29-Jan-20 5:04
A D Rosser29-Jan-20 5:04 
AnswerRe: Application wide information into classes in referenced DLL's Pin
Gerry Schmitz28-Jan-20 4:40
mveGerry Schmitz28-Jan-20 4:40 
GeneralRe: Application wide information into classes in referenced DLL's Pin
A D Rosser29-Jan-20 5:13
A D Rosser29-Jan-20 5:13 
GeneralRe: Application wide information into classes in referenced DLL's Pin
Eddy Vluggen29-Jan-20 6:48
professionalEddy Vluggen29-Jan-20 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.