Avatar of dawber39
dawber39
Flag 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

VBAMicrosoft Access

Avatar of undefined
Last Comment
Jim Dettman (EE MVE)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
David Favor

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
David Favor

Aside: Having written several custom MTAs for various projects over the last 20+ years.

I don't recommend this.
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
David Favor

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.
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
David Favor

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.
Gustav Brock

You may be better off using CDO:

VBA – CDO Mail

Here you can easily set the port no.
dawber39

ASKER
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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Scott Fell

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.

Scott Fell

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. 
David Favor

SWAKS runs on any OS - Linux + OSX + Windows + whatever.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Jim Dettman (EE MVE)

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.
David Favor

@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.
Scott Fell

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


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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
dawber39

ASKER
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
dawber39

ASKER
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) 
Jim Dettman (EE MVE)

 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
Your help has saved me hundreds of hours of internet surfing.
fblack61