POST FOR LATER USE
POST FOR LATER USE
A Folk, A Forum, A Fuhrer ….
In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
This is the example coding used throughout the next posts
Part 1
Log in and enable 2 – Step Verification https://excelfox.com/forum/showthrea...ll=1#post19038
https://excelfox.com/forum/showthrea...age3#post19038
Part 2 Generate Apps Password https://excelfox.com/forum/showthrea...ll=1#post19039
https://excelfox.com/forum/showthrea...age3#post19039
Part 3 Using a gmail "Apps password" in a CDO send mail coding https://excelfox.com/forum/showthrea...ll=1#post19040
https://excelfox.com/forum/showthrea...age3#post19040
Code:Option Explicit Sub SendUsinggmail() Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets.Item(1) Rem EMail send 'For info see: http://www.excelfox.com/forum/showthread.php/2233-Urgent-support-needed-Multiple-emails-multiple-Excel-workbooks-at-once#post10519 'Working at my end With my With End With Created LCDCW Library, (LCD 1.0 Library ) (Linking Configuration Data_Cods Wollups) With CreateObject("CDO.Message") ' -Linking Cods Wollups-------- Dim LCD_CW As String: Let LCD_CW = "http://schemas.microsoft.com/cdo/configuration/" .Configuration(LCD_CW & "smtpusessl") = True ' .Configuration(LCD_CW & "smtpauthenticate") = 1 ' ' ' Sever info .Configuration(LCD_CW & "smtpserver") = "smtp.gmail.com" ' The mechanism to use to send messages. .Configuration(LCD_CW & "sendusing") = 2 .Configuration(LCD_CW & "smtpserverport") = 25 ' .Configuration(LCD_CW & "sendusername") = "mail2taste@gmail.com" ' .Configuration(LCD_CW & "sendpassword") = "mvxyzxjfgxabcbwo" ' - This is the so called "App Pasword" '_- https://eileenslounge.com/viewtopic.php?p=300957#p300957 ' "FallyOverStkPlop.!*" ' "qkl4diPlopsyPoo.!*" ' .Configuration(LCD_CW & "sendusername") = "YourEMailAddress" ' .Configuration(LCD_CW & "sendpassword") = "YourEMailPassword" ' Optional - How long to try .Configuration(LCD_CW & "smtpconnectiontimeout") = 30 ' ' Intraction protocol is Set/ Updated .Configuration.Fields.Update ' 'End With ' ---------------------- my Created LCDCW Library 'With ' --- ' Data to be sent------ my Created LCDCW Library Dim strHTML As String: Let strHTML = "" & ws.Range("B2").Value & "
How are you Today?
" .To = "doc.aelstein@gmail.com" ' .CC = "doc.aelstein@t-online.de" '.CC = "doc.aelstein@gmail.com" '.CC = "excelvbaexp@gmail.com" '.BCC = "" .from = """SendingFrom gmail""" .Subject = ws.Range("A2").Value .htmlbody = strHTML '.AddAttachment ThisWorkbook.Path & "AnyFile.xyz" .Send ' Do it End With ' CreateObject("CDO.Message") -----my Created LCDCW Library End Sub
That coding when run, will send some simple text from range A2:B2
https://i.postimg.cc/tTxWWhK0/Coding...-via-gmail.jpg
Coding send simple text via gmail.JPG
Last edited by DocAElstein; 11-15-2022 at 05:43 PM.
A Folk, A Forum, A Fuhrer ….
In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
The ProblemPreviously we could use our normal Username and password for any gmail account in a CDO send mail type coding, (provided that we make one adjustment to our default account settings: We must enable less secure apps in gmail account
https://www.youtube.com/watch?v=Ee7PDsbfOUI )
However, since end of May 2022, Google gmail are usually not allowing this to be done.
https://i.postimg.cc/DwWgVM37/Less-S...-available.jpg
Less Secure Apps no longer available.JPG
So if we now run a previously working CDO send mail which uses a normal free mail gmail account, then we experience the typical error which we used to get if we had not enable less secure apps:
https://i.postimg.cc/bNVTBjM6/Typica...ecure-Apps.jpg
TypicalErrorForNoEnableLessSecureApps.jpg
In this and the next and nearby posts, a solution will be discussed.
A Solution
The short answer:
There has been in parallel for some time, (I don’t know exactly how long), another way to use gmail in CDO send type codings. It finally works similar to how other Email providers have always organised these things: You need to organise a second password to be used in things such as the CDO send mail codings.
The solution often goes under the names of, or you hear often the word when discussing these things of: _ "2 step verification"_ ; _ "Apps passwword"
Here is the shortened story of what you actually do:
There are broadly speaking 2 main parts to what you do
_Part1) You must enable (Turn on) 2 step verification on the gmail account
_Part2) You must generate an "Apps password"
_3) That "Apps password" is now an extra second password for that gmail account which, amongst other things, is what you use in the sendpassword part of the configurations in a CDO send message type coding. ( In other words, you no longer use your main password in the coding. Instead use the generated "Apps password". )
Ref
https://stackoverflow.com/questions/...dditional-info
https://stackoverflow.com/questions/...60767#54960767
Last edited by DocAElstein; 11-16-2022 at 12:34 PM.
A Folk, A Forum, A Fuhrer ….
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
Here is the shortened story of what you actually do:
There are broadly speaking 2 main parts to what you do
_Part1) You must enable (Turn on) 2 step verification on the gmail account
_Part2) You must generate an "Apps password"
_3) That "Apps password" is now an extra second password for that gmail account which, amongst other things, is what you use in the sendpassword part of the configurations in a CDO send message type coding. ( In other words, you no longer use your main password in the coding. Instead use the generated "Apps password". )
https://eileenslounge.com/viewtopic....300957#p300957
The full detailed walkthrough story
Part 1 Log in and enable 2 – Step verification
_1) Log in to your gmail account as usual. _ https://accounts.google.com/ServiceLogin
https://i.postimg.cc/XJCfXHzS/1-Log-in-username.jpg
https://i.postimg.cc/GmKYhMkt/1-Log-in-Password.jpg
(This should be the account you want to use to send Emails using the CDO send mail type coding)
( _1b) If you are already logged into your gmail Email, then go to Manage your Google Account
https://i.postimg.cc/P5Sz78wc/1b-Man...le-Account.jpg
_2) Go to Security
https://i.postimg.cc/yxCFRmMJ/2-Security.jpg
_3) Go to 2- Step verification
https://i.postimg.cc/6pWfzhyn/3-2-Step-Verification.jpg
https://i.postimg.cc/DzDQvk5P/3-go-t...rification.jpg
_3b) You may probably need to log in again
https://i.postimg.cc/PfDyqxgp/3b-Pos...g-in-again.jpg
, and on doing so you will likely be asked to make some verification of some sort or another. (Typically I use the default SMS, which then arrives on my mobile phone)
https://i.postimg.cc/1zYB8NR6/3b-Ver...g-in-again.jpg
https://i.postimg.cc/V6xFRQCk/3b-Ver...bile-phone.jpg
https://i.postimg.cc/bwp3WhFG/3b-Ver...g-in-again.jpg
_4 ) The 2 –Step verification setting up proceeds
https://i.postimg.cc/s22KfJzs/4-proc...ion-set-up.jpg
_4b) Once again we are typically asked for verification
https://postimg.cc/KKBBVjMv jpg
https://i.postimg.cc/gkvggJ4F/4b-onc...rification.jpg
Add verification code https://i.postimg.cc/gkvggJ4F/4b-onc...rification.jpg
_5) We finally get to turn it on
https://i.postimg.cc/Z5HVhM1w/5-Fina...turn-it-on.jpg
_5b) We are finally turned on: We have 2- Step verification enabled.
https://i.postimg.cc/br19VCxH/5b-We-...-turned-On.jpg
So that’s it, finally for the first part, 2 – Step Verification is turned on
Notes:
_ Google gmail is very security conscious, and during the process you will likely get security warnings many times and likely be asked to confirm that you are the one doing things to your account. You should try to respond to these quickly, or else they may think something bad is going on and they will block your account which will throw an almighty spanner in the works and things will get very complicated!!
https://i.postimg.cc/DyVCQsrP/Floode...ity-Alerts.jpg
_ from now on, you will likely have a more complicated , 2 step verification process when trying to log into this gmail Email account
https://i.postimg.cc/pLRzvN53/We-now...il-account.jpg
https://i.postimg.cc/SR9CSkrb/We-now...il-account.jpg
https://i.postimg.cc/XNBwck01/We-now...il-account.jpg
In the next post we look at the second part, part 2 , of what you have to do, creating/ generating an "Apps password"
Last edited by DocAElstein; 03-20-2023 at 11:38 PM.
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
Here is the story so far
We have done _Part_1) , enabled (Turned on) 2 step verification on the gmail account
We now need to do _Part2) generate / create an "Apps password"
_Part2) generate / create an "Apps password"
The start point is getting logged into the gmail account that you want to use in the CDO send Mail coding. ( see sections _1) and _2) from the previous post https://excelfox.com/forum/showthrea...ll=1#post19038
https://excelfox.com/forum/showthrea...age3#post19038 )
Go to App passwords ( Note it shows None, because we have not got any yet )
Click on the file >
https://i.postimg.cc/t4LsFjJm/Go-to-...n-the-file.jpg
As ever, we will be asked to verify https://i.postimg.cc/jSWWW5x7/verify-again.jpg , and I usually choose to get an SMS on my mobile phone
https://i.postimg.cc/BQ7LQD03/verify...bile-phone.jpg
https://i.postimg.cc/g2rhvsDr/verify...bile-phone.jpg
https://i.postimg.cc/sfcGqqHv/verify...bile-phone.jpg
We now need to make some selections
https://i.postimg.cc/pr2hyJrW/We-now...selections.jpg
I chose Mail and Windows Computer – that was a bit of a guess on my behalf. I am using CDO mail send coding on my LapTop.
https://i.postimg.cc/nr0sm99v/make-s...tions-Mail.jpg
https://i.postimg.cc/j56nsFs3/make-s...s-Computer.jpg
I create ( generate )
https://i.postimg.cc/B6f1f0G1/I-create-Generate.jpg
I have a 16 character code Generated for me
https://i.postimg.cc/KYMgWYC2/I-have...-Generated.jpg
Note: It is probably advisable to copy this and keep it stored safely somewhere for future reference.
It should be a 16 character text string, probably looking something like this
nvutkxjfkxyzdbwo
That’s it. That is the so called apps password
https://i.postimg.cc/nh5DTmR2/Thats-it-finished.jpg
We are now ready to use this newly created (Generated) app password in a CDO send mail coding
In the next post, Part3, we will use this newly created (Generated) app password in a CDO send mail coding
Last edited by DocAElstein; 03-20-2023 at 11:38 PM.
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
Here is the story so far
We have done _Part_1) , enabled (Turned on) 2 step verification on the gmail account
and
_Part2) generate / create an "Apps password"
This next part, Part3, we will use this newly created (Generated) app password in a CDO send mail coding
Part 3) Using a gmail "Apps password" in a CDO send mail coding
We have already done the hard work. Now all we have to do is go to any CDO send mail coding that had previously worked using the normal password, and now replace that password with our newly created Apps Password
https://i.postimg.cc/c1XvvtnF/The-se...p-Password.jpg The sendpassword should be the App Password.JPG
If we now run that coding, we should now have success.
In that example coding, I was attempting to send an Email to my Google freemail gmail.com account and my German Telekom freemail t-online.de account,
https://i.postimg.cc/0yJjXtH4/Sendin...m-accounts.jpg Sending on my gmail and telekom accounts.JPG
and, Bingo! – it worked:
https://i.postimg.cc/d1wbd1yB/Arrive...m-freemail.jpg
https://i.postimg.cc/Dzkkv5fR/Arrived-at-my-gmail.jpg
Arrived at my German Telekom freemail.JPGArrived at my gmail.JPG
Ref
https://stackoverflow.com/questions/...dditional-info
https://eileenslounge.com/viewtopic....300925#p300925
Last edited by DocAElstein; 03-20-2023 at 11:39 PM.
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
https://eileenslounge.com/viewtopic....301029#p301029
Remove Apps Password and turn off 2 – Step Verification
Remove Apps Password
https://i.postimg.cc/44v6h3CJ/Manage...le-Account.jpg
https://i.postimg.cc/qqG2f1ct/Security.jpg
https://i.postimg.cc/0QDpnkb0/App-passwords.jpg
https://i.postimg.cc/g22HpbTG/Log-in...fy-its-you.jpg
https://i.postimg.cc/bwVHNV7k/Verify...s-you-Text.jpg
https://i.postimg.cc/fbFK5q5D/verifi...bile-Phone.jpg
https://i.postimg.cc/rFc9hrG0/Verify...-on-Mobile.jpg
https://i.postimg.cc/ZnzLz91Q/Delete-App-password.jpg
That’s it (https://i.postimg.cc/43KvKbGM/app-password-revoked.jpg )
Turn off 2 – Step Verification
https://i.postimg.cc/44v6h3CJ/Manage...le-Account.jpg
https://i.postimg.cc/qqG2f1ct/Security.jpg
https://i.postimg.cc/tgL3FZCg/Signin...rification.jpg
https://i.postimg.cc/g22HpbTG/Log-in...fy-its-you.jpg
https://i.postimg.cc/bwVHNV7k/Verify...s-you-Text.jpg
https://i.postimg.cc/fbFK5q5D/verifi...bile-Phone.jpg
https://i.postimg.cc/rFc9hrG0/Verify...-on-Mobile.jpg
https://i.postimg.cc/x8G3ffQ1/TURN-OFF.jpg
https://i.postimg.cc/8kLHBHvg/TURN-OFF.jpg
That’s it
Last edited by DocAElstein; 11-17-2022 at 02:38 PM.
A Folk, A Forum, A Fuhrer ….
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
Last edited by DocAElstein; 11-17-2022 at 01:14 PM.
A Folk, A Forum, A Fuhrer ….
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
nndbds
Ref
https://stackoverflow.com/questions/...dditional-info
https://eileenslounge.com/viewtopic....300925#p300925
Last edited by DocAElstein; 11-17-2022 at 01:14 PM.
A Folk, A Forum, A Fuhrer ….
…continued … In support of this forum post
https://eileenslounge.com/viewtopic.php?f=27&t=38916
ncsnss
Ref
https://stackoverflow.com/questions/...dditional-info
https://eileenslounge.com/viewtopic....300925#p300925
Last edited by DocAElstein; 11-17-2022 at 01:14 PM.
A Folk, A Forum, A Fuhrer ….
Bookmarks