Link to home
Start Free TrialLog in
Avatar of dawber39
dawber39Flag for United States of America

asked on

vbSendMail modification

I am trying to add a port number, TLS, and maybe IMAP to the following vbSendMail code}


Option Compare Database
Option Explicit

Private WithEvents poSendMail As MyMail.clsSendMail
' Reference to c:\windows\system\MyMail.OCX
'
Private Sub btnSend_Click()
    btnSend.Caption = "Sending"
    Set poSendMail = New MyMail.clsSendMail
    With poSendMail
        .SMTPHost = Form!txtServer ' Required the fist time, optional thereafter
        .UseAuthentication = True
        .Username = "example@comcast.net"
        .Password = "password"
        .From = Form!txtFrom                        ' Required the fist time, optional thereafter
        .FromDisplayName = Form!txtFromName         ' Optional, saved after first use
        .Message = "<HTML><BODY>" & Form!txtMsg & "</BODY></HTML>"
        .AsHTML = True ' Optional
        .Recipient = Form!txtTo
        .CcRecipient = Form!txtCC
        .RecipientDisplayName = Form!txtToName
        .Subject = Form!txtSubject
        .Attachment = Text20 & ";" & Text22 & ";" & Text24
        .RequestReceipt = Form!cbRequestReadReceipt
        .Send
    End With
    DoCmd.Quit
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Aside: Having written several custom MTAs for various projects over the last 20+ years.

I don't recommend this.
Avatar of dawber39

ASKER

This is just used for sending two emails once a day - is there anyway to bypass the required TLS and just add port 587? Comcast made some changes to their Xfinity connect which now includes a checkbox to by pass security on 3rd party programs, but the checkbox has no effect. I just need an SMTP server to allow these two emails through. Any suggestions? I thought that it would be as simple as adding two or three lines

Richard
You asked, "is there anyway to bypass the required TLS and just add port 587?"

Maybe.

1) If you run the port 587 listener, you can turn of TLS... and this means anyone will be able to hack your mail sending + send mail as you, so if this is a concern... which, to me, it should be... best not open your email for anyone to hack.

2) If you don't run/control the port 587 listener... no Mail Relay service (in their right mind) would disable TLS mail submission, as this would me any random hacker could use their Mail Relay service to send SPAM, which would trigger the service potentially being RBL'ed.

So you can only disable this if you own the port 587 listener.
You asked, "I just need an SMTP server to allow these two emails through. Any suggestions?"

There's a simple solution for this.

Use SWAKS to send your email.

So rather than connecting to your port 587 listener directly, you hand off to SWAKS to do the delivery.

https://www.experts-exchange.com/questions/29215959/Cannot-send-emails-Linux-command-line-to-Google-SMTP.html provides a good overview of command line options to pass, to send a port 587 authenticated email.
You may be better off using CDO:

VBA – CDO Mail

Here you can easily set the port no.
Can always count on the people up here for advice, never fails. Even when the answer is not found, these experts have pushed me in the right direction. Thank you for your time

Richard
Was that really the answer?  Gustov is correct, this should work with what you are doing.

The issue is more than likely using a relay with your comcast account.

Also note that David's solution is not only a command line, it is also for Linux.

If you are using VBS or VBA, you have CDO built in and that is what you should use if you are using SMTP. Otherwise, there are API's you can use such as sendgrid, mailchimp and a good handful of others that can send mail without smtp. 
SWAKS runs on any OS - Linux + OSX + Windows + whatever.
Just an FYI, on this:

"This is just used for sending two emails once a day - is there anyway to bypass the required TLS and just add port 587?"

The option in vbSendMail is SMTPPort

However vbSendMail was last updated in 2003 and doesn't support any form of authentication or security other than logon.

Jim.
@Gerwin, I can understand why you unmarked my comment as one good solution for this question.

If you have a lack of experience + understanding about VB + SMTP in general I'll explain these for you.

1) VB has no facility for submitting TLS SMTP messages.

2) You could write this code, likely months of work.

3) Or you could install a full MTA - OpenSMTPD or Postfix or EXIM or many others - which will likely take a few days, maybe weeks, unless a person is used to this type of work.

4) You could rewrite SWAKS in VB, which will be the same as #2, likely months of work.

5)  Or you could write your own MTA in some other language, likely years of work.

So... since you unmarked my comment as the answer, provide your solution to provide this person with another working solution.

I look forward to reading your solution, as I'm always up for learning something new.

Since I use SWAKS daily... several 100s of instances solving problems similar to this question, if you have a better solution, that will be great.
vba or vbs should use CDO as noted by Gustov https://www.tachytelic.net/2018/12/email-vbscript-vba-office-365/ and that will not require adding a third party program.

Using the third party program can work, that means installing it, then running something like

Shell("YOUR_PROGRAM_OPTIONS")  
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-function

Further on SWAKS, as noted from the documentation page, it is not an easy and out of the box solution for windows as it may be for linux.
 http://www.jetmore.org/john/code/swaks/installation.html
User generated image

If that is the solution that dawber39 used, that is fine. But for anybody else, the way to go is using Gustov's recommendation of CDO with the proper credentials.
I selected the comment as the answer I did - because as always - if I don't get the answer I am looking for, I can always count on being led in the right direction, and Liinux or not - the idea was still there and led me in the right direction. I do not want to use a third party utility!!! See my comment of praise on your FaceBook page
Furthermore - contrary to an earlier comment. I have come up with a way to Authenticate vbSendMail - so there is a way.

I've been a member here since forever, and I do not appreciate having what I select as an answer rescinded or criticized.

Thanks for vote of confidence

Richard a.k.a. dawber39 (that's how old I was when I joined) 
 If you would please outline how you got it to authenticate because as far as I know there is no support for TLS  or any of the more advanced methods of authentication. It will authenticate with a username and password, but that’s as far as it goes to my knowledge.

Thanks,
Jim