TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aanchal Singh
NA
50
2.7k
Asynchronously sending Emails in Vb.net?
Jun 16 2020 12:59 AM
While sending the email using async getting error.
Public
Async
Function
SendEmail(
ByVal
EmailToIds
As
String
,
ByVal
Subject
As
String
,
ByVal
Message
As
String
,
Optional
ByVal
EmailCcIds
As
String
=
""
,
Optional
ByVal
MailAttachment
As
String
=
""
,
Optional
ByVal
FromEmailType
As
Integer
= 0,
Optional
EmailBccIds
As
String
=
""
)
As
Task
Dim
EmailPwd()
As
String
Dim
FromEmail, Password
As
String
'Dim objSmtp As SmtpClient
Dim
objMail
As
MailMessage
Dim
objAttachment
As
Attachment
Try
EmailPwd = GetEmailPassword(FromEmailType).Split(
"|"
)
FromEmail = EmailPwd(0)
Password = EmailPwd(1)
objMail =
New
MailMessage
objMail.From =
New
MailAddress(FromEmail)
objMail.Subject = Subject
objMail.IsBodyHtml =
True
objMail.Body = Message
objMail.
To
.Add(EmailToIds)
If
Len(EmailCcIds) > 0
Then
objMail.CC.Add(EmailCcIds)
End
If
If
Len(EmailBccIds) > 0
Then
objMail.Bcc.Add(EmailBccIds)
End
If
If
MailAttachment <>
""
Then
objAttachment =
New
Attachment(MailAttachment)
objMail.Attachments.Add(objAttachment)
End
If
Using objSmtp =
New
SmtpClient()
objSmtp.Host = ConfigurationSettings.AppSettings(
"SmtpClient"
)
objSmtp.DeliveryMethod = SmtpDeliveryMethod.Network
objSmtp.UseDefaultCredentials =
False
objSmtp.Credentials =
New
NetworkCredential(FromEmail, Password)
objSmtp.Port = 587
objSmtp.EnableSsl =
True
ServicePointManager.ServerCertificateValidationCallback =
Function
(s
As
Object
, certificate
As
X509Certificate, chain
As
X509Chain, sslPolicyErrors
As
SslPolicyErrors)
True
Await objSmtp.SendMailAsync(objMail)
End
Using
Catch
ex
As
Exception
throw rx
End
Try
End
Function
Error : Failure Sending Mail.
Kindly help for the same.
Reply
Answers (
2
)
Reset Password in c# with linq.
Facial recognition issue