Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Does anyone know have any third party freeware can replace EASendMailObj.Mail? Or any method to use the EASendMailObjLib.Mail become freeware? Because now..I use this to send email,the system say Smtp.LicenseCode = "TryIt" has expired already.The following is my code:

VB
Dim Smtp As New EASendMailObjLib.Mail
                    Smtp.LicenseCode = "TryIt"

                    Smtp.FromAddr = eid  '"ab@mail.com"
                    Smtp.AddRecipientEx(email, 0)

                    Smtp.Subject = "abcde"
                    Smtp.BodyText = "abcde"

                    '' Add attachment from local disk
                    If Smtp.AddAttachment(pdfFile) <> 0 Then
                        MsgBox("Failed to add attachment with error:" & Smtp.GetLastErrDescription())
                    End If

                    Smtp.ServerAddr = server '"smtp.gmail.com"
                    Smtp.ServerPort = port ' 465

                    '' detect SSL/TLS automatically
                    Smtp.SSL_init()

                    Smtp.UserName = eid '"ab@mail.com"
                    Smtp.Password = pass '"123"

                    If Smtp.SendMail() = 0 Then
                        '' MsgBox("email was sent successfully!")
                        Label1.Text = "1"
                    Else
                        MsgBox("failed to send email with the following error:" & Smtp.GetLastErrDescription())
                    End If
                Else
                End If
            Next
            If Label1.Text = "1" Then
                MsgBox("email was sent successfully!")
            End If
            Label1.Text = ""
        End If

I solve this problem about 1 week already,but also cannot solve it.Hope u guys can help me,really headache for this part.
Thanks you in advance.

[Edit]Code block formatting added[/Edit]
Posted
Updated 17-Sep-19 3:09am
v3

1 solution

Hi,

You really don't need to use a third-party library to send an email. Just use a System.Net.Mail.SmtpClient:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx[^]
Sending an Email in C# with or without attachments: generic routine.[^] (C#)
Sending an Email in C# with or without attachments: generic routine.[^] (VB.NET)
Example:
VB
Imports System.Net
Imports System.Net.Mail   ' add these lines at the top of your file
VB
Dim Smtp As New SmtpClient(server, port)
Dim msg As New MailMessage()
msg.From = New MailAddress(eid)
msg.[To].Add(email)
msg.Subject = "abcde"
msg.Body = "abcde"
msg.IsBodyHtml = True
' if your email body is not HTML, change this into false or remove this line
msg.Attachments.Add(New Attachment(pdfFile))
Smtp.EnableSsl = True
Smtp.Credentials = New NetworkCredential(eid, pass)
Try
	Smtp.Send(msg)
	Label1.Text = "1"
Catch e As Exception
	MsgBox("failed to send email with the following error:" + e.Message)
End Try
' now, add other code if you want

Hope this helps.
 
Share this answer
 
v2
Comments
Adrian4263 24-Jun-13 22:37pm    
Do not need to use third-party library?Can Show me a simple example? Or modify my code above? Because the link you given,I'm not understand so much.Thanks
Thomas Daniels 25-Jun-13 2:45am    
I added an example.
Adrian4263 25-Jun-13 2:56am    
Okay,I have a question.What server part should I write?Smtp?
Thomas Daniels 25-Jun-13 2:58am    
Yes, in your case "smtp.gmail.com"
Adrian4263 25-Jun-13 3:05am    
Okay. msg.From = New MailAddress(eid) <<The meail address is write my e-mail address is it?And Smtp.Credentials = New NetworkCredential (eid, pass)<< my id n password replace the NetworkCredential or replace in the bracket?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900