UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Access Send Email With Using Outlook, Access 2016    
 
   
Debbie10
post Jan 23 2020, 12:42 PM
Post#1



Posts: 1
Joined: 23-January 20



I am new to VBA code and do not have any experience with HTML. I have a project to send Christmas emails from access without using outlook. The problem I am having is the body of the email, which contains text, picture and background. Here is the code below. The body of the email was a word document converted to web page filtered. However, when I do a test email it has a red X for the picture and not all the text displays. Has anyone been able to do this successfully? Any suggestions?

Sub SendChristmasX()

Dim cdoConfig As Object
Dim cdoMessage As Object
Dim Configuration As Object

Set cdoConfig = CreateObject("CDO.Configuration")
Set cdoMessage = CreateObject("CDO.Message")

Open "C:\AccessScript\Christmas2019.HTM" For Input As 1
Do While Not EOF(1)
'Input #1, strLine
Line Input #1, strLine
Strhtml = Strhtml & strLine
Loop

'Setup server configuration
With cdoConfig.Fields
.Item("http://schemas.microsoft.com/CDO/configuration/smtpserver") = "mail.gmail.com" 'smtp address
.Item("http://schemas.microsoft.com/CDO/configuration/smtpserverport") = 25 'smtp port number
.Item("http://schemas.microsoft.com/CDO/configuration/smtpauthenticate") = 2 'clear text authentication
.Item("http://schemas.microsoft.com/CDO/configuration/sendusing") = 2 'smtp over the network
.Item("http://schemas.microsoft.com/CDO/configuration/smtpconnectiontimeout") = 60 'timeout in seconds

'warning: it's a security risk to hard-code your username and password
.Item("http://schemas.microsoft.com/CDO/configuration/sendusername") = "debbie"
.Item("http://schemas.microsoft.com/CDO/configuration/sendpassword") = "password"
.Update
End With
'build and send email message
Set MyDb = CurrentDb
Set rs = MyDb.OpenRecordset("tblChristmasx", dbOpenDynaset)

Do Until rs.EOF
With cdoMessage
Set .Configuration = cdoConfig
.Subject = "AMCI Christmas"
.From = "debbie@gmail.com"
.To = rs!EmailAddress
.HTMLBody = Strhtml
.Send
End With
rs.MoveNext
Loop

Set cdoConfig = Nothing
Set cdoMessage = Nothing
Set Configuration = Nothing

Close 1
End Sub
Go to the top of the page
 
theDBguy
post Jan 23 2020, 12:51 PM
Post#2


UA Moderator
Posts: 77,506
Joined: 19-June 07
From: SunnySandyEggo


Hi. Welcome to UtterAccess! welcome2UA.gif

Just curious if you saw my response to your other thread?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
theDBguy
post Jan 23 2020, 01:18 PM
Post#3


UA Moderator
Posts: 77,506
Joined: 19-June 07
From: SunnySandyEggo


Update: Looks like Colin responded there too with a link to a sample db. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
isladogs
post Jan 23 2020, 05:03 PM
Post#4


UtterAccess VIP
Posts: 2,185
Joined: 4-June 18
From: Somerset, UK


Debbie
As DBG stated both of us have already responded at AWF
Please read this article about the etiquette of cross posting

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st February 2020 - 11:32 AM