Avatar of RayT
RayT
Flag for United States of America asked on

Sending email using SMTP

How do you send an email using SMTP, Visual Basic and Visual Studio 2019?  I can't get it to work!!!
Visual Basic.NETMicrosoft Visual Studio

Avatar of undefined
Last Comment
Chinmay Patel

8/22/2022 - Mon
it_saige

What are your implementation details?

-saige-
David Favor

Sending is fairly straight forward. Normally you'll use an SMTP library for this, rather than writing your own SMTP code.

As it_saige mentioned, we'll have to see your code to provide assistance.
David Favor

Aside: There's a big difference between sending email + having email delivery.

You can't just setup SMTP, send an email, imagine it will every arrive at a recipient.

For high deliverability email, you'll use a relay service like https://MailGun.com or setup your own sending infrastructure.

https://www.experts-exchange.com/questions/29158183/Backloading-emails-into-gmail.html covers a minimal checklist of how to get started, if you require building a high deliverability, SMTP infrastructure.

Likely best to start with https://MailGun.com, then move on to setting up your own infrastructure.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Éric Moreau

What have you tried? System.Net.Mail?

Your issues might come from your relay. You need to use one (Gmail, O365, ...). What are you using?

Have a look at https://www.emoreau.com/Entries/Articles/2007/09/Using-SystemNetMail.aspx
Chinmay Patel

Hi Ray,

As other experts have suggested, without looking at your code it is next to impossible to guess what is the real culprit.
Also, just so you know, Microsoft's current recommendation is to use library like MailKit
https://github.com/jstedfast/MailKit
per, https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=netframework-4.8

Currently, SmtpClient is supported only to provide platform compatibility and should be avoided, if possible.
https://github.com/dotnet/platform-compat/blob/master/docs/DE0005.md

Let me know if you need more information on the same.

Regards,
Chinmay.
RayT

ASKER
Chinmay,

How do you use MailKit?  Is it free?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Chinmay Patel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
RayT

ASKER
Thanks!  Microsoft move away from the email business some time ago (https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=netframework-4.8) and it's been costly to find solutions.  I'm currently paying an annual fee for a solution and I was curious to find a free solution.
David Favor

If you opt for using MailKit or any other MTA-esque code which sends email from IPs you own, you must still go through all the IP setup checklist items for every sending IP you use.

https://www.experts-exchange.com/questions/29158183/Backloading-emails-into-gmail.html

If you expect to have any level of deliverability.

Remember: Sending email is easy. Having email deliver is a monumentally complex task.
Chinmay Patel

Hi Ray,

With advent of .Net Core, I think almost all products will have a free, open source, community driven (But Microsoft backed/overwatched) alternative.

Let me know if there are other similar challenges you are facing, I might be able to drop in some pointers.

Regards,
Chinmay.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes