简体   繁体   中英

Visual studio 2015 code not working on Visual Studio code IDE

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM