Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbsendmail - embed html 1

Status
Not open for further replies.

DickDavies

IS-IT--Management
Jan 4, 2002
22
0
0
GB
I have created a mailshot routine which passes list of email addresses to vbsendmail ('BCC' field). The basics all work fine and can attach file and send mails ok. Ideally I need to embed the attached html into the message body, I have followed the 'AsHTML' instructions from the vbSendMail help but cannot get the html to appear in the message body. (Test by sending to myself and I get the 'red cross' in the body of the message even though my email settings enable attachments).
Thanks
 
Have now managed a workaround by adding a 'stationery' input to my vbsendmail form, reading the htm file and appending to the message - now doesn't need an attachment.

Now for the mailshot...
 
Hi,

I have vbSendMail working.

I am attempting to have the body of the email as HYML instead of plain text.
Could you elaborate on how you achieved that ?

Thanks,
Rob Crombie
robhp AT iprimus.com.au

PS
My dream is to have 'email merge', which I believe I can achieve, after I solve the text as HTML problem.

I will be happy to share my solution with you.
 
Hi,

Sorry for delay in reply.
Basically I create the complete message as an htm file and read this file in line by line and add to the message text as per the code below.

(Any graphics included in the htm reside on our web server).

-----------------------------------------------------------
Private Sub SetHTMMessage()
' Read selected file (.htm) and add line by line to message text.
' (This embeds the htm - no need for attachment or stationery)
Dim Buffer1 As String

On Error GoTo BadFile
Open txtHTM.Text For Input As #1 ' pre-prepared htm file
On Error GoTo 0
Do Until EOF(1)
Line Input #1, Buffer1
txtMsg.Text = txtMsg.Text + Buffer1 + vbCrLf ' append text contents of htm file to the message.
Loop
Close #1
ckHtml.Value = 1 ' Force html
Exit Sub
BadFile:
On Error GoTo 0
MsgBox ("Cannot open file: " + txtHTM.Text)
End Sub
------------------------------------------------------------

 
Dick,

Have you considered reading the entire file at once, rather than looping line-by-line?

Code:
    intInput = FreeFile
    Open strFilename For Input As #intInput
    strFileContents = Input$(LOF(intInput), #intInput) '-- Read the entire file into a string
    Close #intInput
This is more compact and works just as well, if not better.
 
Thank you both, for your response, I will give that a try.

Regards,
Rob
 
I have used Thunderbird to create a message, and TB has also embedded (base64) a bmp file like a letterhead across the top.
It works well. (There is no attached file, and no link to the web to get the image)

If I copy the email source into a file, I assume I can do the trick described by Dick and harebrain ?

What portion of the email source file should I cut out, to place into the text file ?

Thanks,
Rob
 
Have you tried it? What does the file look like?

The base64 data should have sentinels around it, and, assuming that's what you want to "cut out," those would be what to look for.
 
Hi All,

1. I wasn't aware of the command to read the entire contents - I will give it a try, thanks.

2. Locating the graphics on our web site seems to give better results on receiving email clients that do not allow attachments (but are ok with web links).

Regards
Dick D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top