Access emails without outlook (1 Viewer)

debbiedoobie10

Registered User.
Local time
Today, 08:02
Joined
Oct 1, 2010
Messages
13
I'm 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'm having is the body of the email which contains text, picture and background. Here is some of the code. The body of the email was a word document converted to web page filtered. But 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?



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


'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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:02
Joined
Oct 29, 2018
Messages
21,358
Hi. I could be wrong; but if you're sending out HTML emails with embedded images, then I think those images may have to be hosted on a web server somewhere.
 

isladogs

MVP / VIP
Local time
Today, 15:02
Joined
Jan 14, 2017
Messages
18,186
Hi Debbie & DBG
Have a look at my CDO EMail Tester example app

The HTML option includes an example image:


The embedded image does not need to be on a web server for this to work

I can't remember whether I've ever done this with a converted Word doc for the HTML body text
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:02
Joined
Oct 29, 2018
Messages
21,358
Hi Colin. Thanks. I'll take a look.
 

isladogs

MVP / VIP
Local time
Today, 15:02
Joined
Jan 14, 2017
Messages
18,186
Debbie
After further testing, you need to be aware that inline images in email are blocked by certain programs.

I sent a copy to 2 different email accounts (IMAP & POP3) and tested opening it in
a) Outlook – image blocked by default (for security) but displayed fine after enabling that setting
b) Windows Mail – small red X rectangle shown instead of image
d) iPhone email – small red X rectangle shown instead of image

Further testing sending to a GMail account
Using Outlook to open Gmail – image displayed
Using Gmail in browser or on iPhone – no image displayed - empty space
Using Windows Mail – small red X rectangle shown instead of image

I can't find any method of over-riding the settings in Windows Mail or GMail

So unfortunately, it looks like your Xmas cards will be hit and miss depending on which email application is used to open them
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:02
Joined
Feb 28, 2001
Messages
26,999
The settings responsible for masking certain images are registry-level security settings, Colin. It would make no sense whatsoever for a sender to be able to override a recipient's security settings. I used to see the little red X boxes all the time with the Navy. I would have to search for the particular setting, but it is available online.

The usual way to fix that is for the recipient to add the sender to the "white list" or "approved sender's list" or whatever that particular browser calls it. However, there is a more pernicious version of that problem that doesn't depend on "safe senders lists." That one takes a registry mod.
 

isladogs

MVP / VIP
Local time
Today, 15:02
Joined
Jan 14, 2017
Messages
18,186
Hi Richard
Perhaps I didn't explain myself well.
With regards to 'over-riding' image settings, I was referring to the end user not the sender.
Whereas I can choose whether to display online images in Outlook, there is no obvious setting to do so in Windows Mail or GMail (for example).
Hence the OP's Plan of sending Xmas card emails with inline images isn't going to work reliably. Instead it would be prudent to send the images as email attachments
 

debbiedoobie10

Registered User.
Local time
Today, 08:02
Joined
Oct 1, 2010
Messages
13
Hi Debbie & DBG
Have a look at my CDO EMail Tester example app

The HTML option includes an example image:


The embedded image does not need to be on a web server for this to work

I can't remember whether I've ever done this with a converted Word doc for the HTML body text
Hi Isladogs
Do you have a sample of the code you used for the body of the email with image?
 

isladogs

MVP / VIP
Local time
Today, 15:02
Joined
Jan 14, 2017
Messages
18,186
The code is in my example app. See the link in post #3. It will work with any image file but jpg files don’t always work well with Access due to their lossy format
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:02
Joined
Feb 28, 2001
Messages
26,999
OK, when the RECIPIENT can't see the e-mails, here are a couple of links.

This is the easier solution:


This is the harder solution when the easy one doesn't work:


The first one is the security center fix. The second one is the registry fix.
 

isladogs

MVP / VIP
Local time
Today, 15:02
Joined
Jan 14, 2017
Messages
18,186
Hi Doc

The two solutions you gave only apply to Outlook where users can also approve images in individual messages from the bar above the message itself

However, these solutions have NO effect on Windows Mail (or GMail) and, as previously stated, there appears to be no method of enabling inline messages in those applications

To illustrate my point, here is the same test message opened in both Outlook and Windows Mail on the same PC
Capture.PNG
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 10:02
Joined
Feb 28, 2001
Messages
26,999
When I did the search for "Cannot view images in mail message" those were the solutions that came up, but there were more. Perhaps if you qualify that with "Gmail" in place of "mail" you might find a different fix. The reason I found those is because after my computer died and I switched (involuntarily) to Win10, I had the problem of the red-x-in-a-box and the fix for me was a registry hack. However, there were many articles besides those. Perhaps one of them might help. I don't use GMail, never have, so wouldn't recognize references to GMail things if I saw them.
 

Users who are viewing this thread

Top Bottom