Excel error when sending a HTML email

glauberludwig

New Member
Joined
Feb 27, 2014
Messages
2
Hello Everybody!

I have an excel file that does (or should do
C:\Users\Glauber\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif
) the organization of files to it's respectively folder.

So this is an automatic task that happens in a backup computer.

This works like this:
1 - Import from .txt file the months of files that it should search for.
2 - Organize the files, creating a "log" for each file and what happened for each one.
2.1 - The log can get many positions (Old file not found, file is being used, file not found, or if it was moved OK).
3 - A row get each file name and the log status and create a string that it used inside a HTML table:
Examples:
<tr><td>File1.pdf</td><td>File is being used</td></tr>
<tr><td>File1.pdf</td><td>File not found</td></tr>
<tr><td>File1.pdf</td><td>N/D</td></tr>
.... For each file listed on folder, a new line.

(bgcolor code gets different for each log status).

So after that, there is a cell that concatenates all cells, where I get a string like:
<tr><td>File1.pdf</td><td>File is being used</td></tr><tr><td>File1.pdf</td><td>File not found</td></tr><tr><td>File1.pdf</td><td>N/D</td></tr>

Here is the VBA core image for this, where: (the notation is in Portuguese - I'm from Brazil)
vba.png




As you can see, Cell AC2 is that cell that has the concatenation of all lines.

"Texto_Final" is where I have a default layout for best apparence of email, and there is, inside of it, the use of "Texto".

So the HTML Body should be like:

--> introduction text before the table....
<table border="3" align="left"><tr><td><b>File</b><td><b>Status</b></td></tr><tr bgcolor="#00FF00"><td>File1.pdf</td><td>File is been used</td></tr><tr bgcolor="#00FF00"><td>File2.pdf</td><td>File not Found</td></tr><tr bgcolor="#00FF00"><td>File3.pdf</td><td>N/D</td></tr></table>

I try to simulate in this website: Tryit Editor v2.0
With this code (a real example): sy5YMhJ3 | shrib.com
and worked as it should. No problem.

In the first image of the VBA code there is a part to get the whole html code to compare what excel has as code and the code that i really receive via e-mail.

But here is my question:
Sometimes the table does not work properly. I think this could be something with limit of caracters in variables, but with that "log part", the cell is completed with the whole string, without any kind of limit (the code has about 3k caracters).

An example of this error happended today, as you can see on this image:
email.png



But if you get the code and see what happens in line of "0814_24138371.pdf" there is what it should be:
<tr bgcolor="#FFFF00"><td>0814_24138371.pdf</td><td>7 - N/D </td></tr>
(yeah, after "N/D" there is 4 spaces)

I know that if i get an extra space between "tr" and "bgcolor", like <tr bgcolor=…., it could happen.
When the list is big (and the table gets many lines), this happens many times among the lines.

Since the HTML code is correct (with the "Try it Yourself" tool) and the excel variable "Texto_Final" gets the complete code (cause its in the "Criar_Log_HTML" cells), what could be happening about I get a different e-mail from what I've written in HTML via excel?

If someone is interested about something this program does, please ask me that i will send the code (can't send the entire file because of data security)

Thanks Everybody!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,215,987
Messages
6,128,125
Members
449,425
Latest member
NurseRich

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