How do i send a TLS mail using VB.net (Need an free easendmail alternative) (1 Viewer)

bjsteyn

Registered User.
Local time
Today, 19:41
Joined
May 15, 2008
Messages
113
Hi i was using easendmail to send mail using TLS until the trial i didn't know about expired, is there any free method in VB.net or external dll i can use to send mail using TLS protorcols.
 

Ranman256

Well-known member
Local time
Today, 13:41
Joined
Apr 9, 2015
Messages
4,339
try SENDOBJECT,(in access)
docmd.SendObject acSendReport ,"rMyReport",acFormatPDF,sTo,,,sSubj,sBody
docmd.SendObject acSendQuery ,"qsMyQuery",acFormatXLS,sTo,,,sSubj,sBody

OR usu there is a .dll or .ocx installed for every app.
Enter VBE, Alt-F11,
menu, tools, references
check mark TLS mail, (or similar object library)

then use the code below, but replace OUTLOOK objects with your TLS.
It may or may not work.

usage:
call Email1(sTo, sSubj, sBody)

Code:
Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody, Optional ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem

On Error GoTo ErrMail

'NOTE : YOU MUST HAVE THE OUTLOOK REFERENCE CHECKED IN VBE; ctl-G, menu,tools, references, Microsoft Outlook XX Object library
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.createitem(olMailItem)

With oMail
    .To = pvTo
    .Subject = pvSubj
    If Not IsNull(pvBody) Then .Body = pvBody
    If Not IsMissing(pvFile) Then .Attachments.Add pvFile, olByValue, 1
    
    '.Display True    
    '.Save    'draft, we are NOT sending...we save as draft
    .Send     
    
End With

Email1 = True
endit:
Set oMail = Nothing
Set oApp = Nothing
Exit Function

ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume endit
End Function
 

sonic8

AWF VIP
Local time
Today, 18:41
Joined
Oct 27, 2015
Messages
998
... is there any free method in VB.net or external dll i can use to send mail using TLS protorcols.


Yes, it's built into the .Net Framework.


First, you should find out what protocol(s) your provider supports.


The recommend namespace for email is System.Net.Mail. However, as far as I know, this supports only explicit SSL/TLS with the STARTTLS command.
This might have changed with .Net 4.6 and later because there where many SSL/TLS enhancements included.


You could also use System.Web.Mail. This namespace supports implicit and explicit SSL/TLS. However, it is marked as deprecated but still work in all current versions of .Net Framework.


In any case, I would suggest you wrap your email code in a custom abstraction layer to easily change it later if requirements, availability and/or capabilities of the used email component change.
 

Users who are viewing this thread

Top Bottom