Sending Comcast email without outlook

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
690
Office Version
  1. 365
Platform
  1. Windows
This worked for a long time and now it doesn't work.
I have read every post on here and no help.
PLEASE HELP or this will run me crazy lol

Sub sending_email_CDO()
Dim filepath As String

filepath = Environ$("temp") & "\" & ActiveWorkbook.Name & ".pdf" 'TODO:change filepath for the temp pdf file
On Error GoTo ErrHandler3:

Range("A1:A5").Select

Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
filepath, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
'Setting up CDOSYS configuration to send out the email
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
.Item("http://schemas.Microsoft.Com/cdo/configuration/smtpusetls") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "My email address"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "my email password"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.comcast.net"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'Also tried 587
.Update
End With

With iMsg
Set .Configuration = iConf
.From = "Your full gmail address here"

.To = "Your full email here"
JUMP_TO_SUBJECT:
.Subject = "TEST"
.HTMLBody = "HELLO"
.AddAttachment (filepath) 'This is Range "A1:A5" of the worksheet that is being sent
.Send
End With

Set iMsg = Nothing
Set iConf = Nothing
Kill filepath

MsgBox "YOUR E-MAIL WAS SENT. "
Exit Sub

ErrHandler3:

MsgBox "YOUR E-MAIL DID NOT GO THROUGH. "

Set iMsg = Nothing
Set iConf = Nothing
Kill filepath
Range("A1").Select
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
When you say it didn't work, what exactly do you mean?
Did it produce message box saying that it didn't work? Or was there no response at all? Did it create the file at least?
I think the first step might be to make your error handling routine a bit more useful and getting it to provide some key information, so I suggest replacing:
VBA Code:
MsgBox "YOUR E-MAIL DID NOT GO THROUGH. "
with
VBA Code:
Msgbox "Error " & Err.Number & " - " & Err.Description
If you run that, let me know what it says - that will give us a clue as to what the cause of the problem will likely be.
 
Upvote 0
I am embarrassed to admit this but I was entering the wrong password. I forgot I changed it.

I was getting an error code and I should have posted it... Sorry

Thank you for your response Dan.
 
Upvote 0
Solution
LOL. That's ok. So does that mean it's working ok?
Also, you didn't have to admit that you had entered the wrong password! You should've had some fun with it and come up with some spectacular story to explain - far more entertaining that way!
 
Upvote 0
I thought about that but if someone else wanted to use that code they would have thought it wouldn't work.

It works fine but you do have to go to the comcast mail site and check the less secure box under the security tab.
 
Upvote 0
Ahh ok - that makes sense. You're far more considerate a person than me! :)
Looking at the code, I didn't see a problem - the only thing that jumped out at me was that you said your username was your email address. Sometimes it's actually not the full email address - especially with corporate email systems, and was eventually going to make that observation if all else failed. But glad you managed to get it going.
 
Upvote 0
Thanks again Dan
I will probably need help with something else that maybe you can help with.
Always nice if you have an individual to ask.
 
Upvote 0
Warning!! You may want to modify the code you posted to remove the "KILL" line ... I copied the code to test, selected my life history as the file... and POOF! Gone!
Well, I exaggerate slightly, but I did lose my file....
Thanks for the code, but not working for me.
I can't seem to find what you mean with "go to the comcast mail site and check the less secure box under the security tab."
 
Upvote 0
I don't quite see how you "lost a file" using the code above. The file that the code deletes is a PDF file that it has also generated.
 
Upvote 0
I see your point. However, I didn't deep-dive into the logic. I just changed the code to use a file that I'm working with. Have you been able to get the code to work with AOL? Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top