Reputation: 3
I have an issue that I've been trying to google and search for many days now and I just can't seem to get it to work. So I'm trying to get Visual Studio Code to work and it works fine to some degree.
This is the code I used in Visual Studio 2015:
var client = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress,
fromPassword)
};
So the issue is that I get an error "The type or namespace name 'SmtpClient' could not be found (are you missing a using directive or an assembly reference?) [netcoreapp1.0]" and "The name 'SmtpDeliveryMethod' does not exist in the current context [netcoreapp1.0]" And yes I've installed nuget and I did install all the libraries I need which is System.Net.Mail and the latest version and it just doesn't work and I have no clue why. Anyone have a suggestion?
Upvotes: 0
Views: 159
Reputation: 5281
System.Net.Mail and its SmtpClient are not yet supported in a .NET Core 1.0/1.1 app.
Looks like it is scheduled for .NET Core 2.0 https://github.com/dotnet/corefx/issues/1006
You can use MailKit for now: https://github.com/jstedfast/MailKit
or maybe SendGrid https://github.com/sendgrid/sendgrid-csharp
Upvotes: 3
Reputation: 4883
Try using a full reference. It seems that the compiler is not finding the reference to that library:
var client = new System.Net.Mail.SmtpClient
Upvotes: 0