473,480 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem sending email in html format

I'm working on a minor bug from an open source bug tracking system
(bugtracket.net). It's a great app, but I don't want to bother the
creator any more than I have to, so I thought I'd pose the question
here.

The problem is with an email that gets sent from the system. In a
nutshell, it's an HTML format email that is choking on the string that
is returned form this function that is added to the email's body:

string get_bug_text(int bugid)
{
// Get bug html
DataRow bug_dr = get_bug_datarow(bugid);

// Create a fake response and let the code
// write the html to that response
System.IO.StringWriter writer = new System.IO.StringWriter();
HttpResponse my_response = new HttpResponse(writer);
print_bug(my_response, bug_dr);
return writer.ToString();
}


(the print_bug function is at the bottom of thie message.)
I'm sure it's something in the string becasue i can set the body of
the email to something else and it is sent fine. And I've seen the
actual html that comes back and it appears to be ok.

THe error is:
The message could not be sent to the SMTP server. The transport error
code was 0x800ccc6a.

And when I look at the actual trace, it's the 'can't access
CDO.message' error. I can post it if someone would find it helpful.

Thanks for any insights!

Rich


///////////////////////////////////////////////////////////////////////
void print_bug (HttpResponse Response, DataRow dr)
{

Response.Write ("<style>");
Response.WriteFile(Server.MapPath("./") + "btnet_base.css");
Response.Write ("\n");
Response.WriteFile(Server.MapPath("./") + "btnet_custom.css");
Response.Write ("</style>");

Response.Write ("<body style=background:white>");
Response.Write (""
+ Util.capitalize_first_letter(Util.get_setting("Sin gularBugLabel","bug"))
+ " ID: <a href="
+ Util.get_setting("AbsoluteUrlPrefix","http://127.0.0.1/")
+ "edit_bug.aspx?id="
+ dr["id"].ToString()
+ ">"
+ dr["id"].ToString()
+ "</a><br>");

Response.Write ("Short desc: <a href="
+ Util.get_setting("AbsoluteUrlPrefix","http://127.0.0.1/")
+ "edit_bug.aspx?id="
+ dr["id"].ToString()
+ ">"
+ HttpUtility.HtmlEncode((string)dr["short_desc"])
+ "</a><p>");

Response.Write ("<table border=1 cellpadding=3 cellspacing=0>");
Response.Write ("<tr><td>Last changed by<td>" + dr["last_updated_user"] +
" ");
Response.Write ("<tr><td>Reported By<td>" + dr["reporter"] + "&nbsp");
Response.Write ("<tr><td>Reported On<td>" +
Util.format_db_date(dr["reported_date"]) + " ");
Response.Write ("<tr><td>Project<td>" + dr["current_project"] + " ");
Response.Write ("<tr><td>Category<td>" + dr["category_name"] + " ");
Response.Write ("<tr><td>Priority<td>" + dr["priority_name"] + " ");
Response.Write ("<tr><td>Assigned<td>" + dr["assigned_to_username"] + " ");
Response.Write ("<tr><td>Status<td>" + dr["status_name"] + " ");

if (Util.get_setting("ShowUserDefinedBugAttribute","1 ") == "1")
{
Response.Write ("<tr><td>"
+ Util.get_setting("UserDefinedBugAttributeName","Yo urAttribute")
+ "<td>"
+ dr["udf_name"] + " ");
}

// Get custom column info (There's an inefficiency here - we just did this
// same call in get_bug_datarow...)

DataSet ds_custom_cols = Util.get_custom_columns(dbutil);


// Show custom columns

foreach (DataRow drcc in ds_custom_cols.Tables[0].Rows)
{
Response.Write ("<tr><td>");
Response.Write (drcc["name"]);
Response.Write ("<td>");

if ((string)drcc["datatype"] == "datetime")
{
object dt = dr[(string)drcc["name"]];

Response.Write (Util.format_db_date(dt));
}
else
{
string s = Convert.ToString(dr[(string)drcc["name"]]);
s = HttpUtility.HtmlEncode(s);
s = s.Replace("\n","<br>");
s = s.Replace(" "," ");
s = s.Replace("\t"," ");
Response.Write (s);
}
Response.Write (" ");
}


// create project custom dropdowns
if ((int)dr["project"] != 0)
{

sql = @"select
isnull(pj_enable_custom_dropdown1,0) [pj_enable_custom_dropdown1],
isnull(pj_enable_custom_dropdown2,0) [pj_enable_custom_dropdown2],
isnull(pj_enable_custom_dropdown3,0) [pj_enable_custom_dropdown3],
isnull(pj_custom_dropdown_label1,'') [pj_custom_dropdown_label1],
isnull(pj_custom_dropdown_label2,'') [pj_custom_dropdown_label2],
isnull(pj_custom_dropdown_label3,'') [pj_custom_dropdown_label3]
from projects where pj_id = $pj";

sql = sql.Replace("$pj", Convert.ToString((int)dr["project"]));

DataRow project_dr = dbutil.get_datarow(sql);


for (int i = 1; i < 4; i++)
{
if ((int)project_dr["pj_enable_custom_dropdown" + Convert.ToString(i)] ==
1)
{
Response.Write ("<tr><td>");
Response.Write (project_dr["pj_custom_dropdown_label" +
Convert.ToString(i)]);
Response.Write ("<td>");
Response.Write (dr["bg_project_custom_dropdown_value" +
Convert.ToString(i)]);
Response.Write (" ");
}
}
}



Response.Write("</table><p>");


// Show comments


if (Util.get_setting("ShowHistoryWithComments", "0") == "1")
{
Response.Write ("Comments and Change History");
}
else
{
Response.Write ("Comments");
}

if (Util.get_setting("ShowHistoryWithComments", "0") == "1")
{
sql = @"select
bc_comment,
isnull(us_username,'') [us_username],
isnull(us_email,'') [us_email],
bc_date,
bc_id,
bc_type,
isnull(bc_email_from,'') [bc_email_from],
isnull(bc_email_to,'') [bc_email_to]
from bug_comments
left outer join users on us_id = bc_user
where bc_bug = $id
order by bc_date " + Util.get_setting("CommentSortOrder","desc");
}
else
{
sql = @"select
bc_comment,
isnull(us_username,'') [us_username],
isnull(us_email,'') [us_email],
bc_date,
bc_id,
bc_type,
isnull(bc_email_from,'') [bc_email_from],
isnull(bc_email_to,'') [bc_email_to]
from bug_comments
left outer join users on us_id = bc_user
where bc_bug = $id
and bc_type <> 'update'
order by bc_date " + Util.get_setting("CommentSortOrder","desc");
}

bool show_initial_comment = false;
if (Util.get_setting("CommentSortOrder","desc") == "desc"
&& Util.get_setting("ShowInitialCommentFirst", "1") == "1")
{

show_initial_comment = true;

// get the initial comment again in a seperate dataset
sql += @"
select top 1
bc_comment,
isnull(us_username,'') [us_username],
isnull(us_email,'') [us_email],
bc_date,
bc_id
from bug_comments
left outer join users on us_id = bc_user
where bc_bug = $id
and bc_type = 'comment'
order by bc_date";
}


sql = sql.Replace("$id", dr["id"].ToString());
DataSet ds_comments = dbutil.get_dataset(sql);


Response.Write ("<p><table border=1 cellspacing=0 cellpadding=4>");


// save this so we can avoid showing the initial comment twice
int initial_comment_id = -1;
if (show_initial_comment)
{
// save the id of the initial comment
foreach (DataRow dr_comments_initial in ds_comments.Tables[1].Rows)
{
initial_comment_id = (int) dr_comments_initial["bc_id"];
Response.Write ("<tr><td><table width=100% ><tr><td align=left>");

Response.Write ("<span>Initial comment posted by ");
Response.Write (Util.format_email_username(
id, (string) dr_comments_initial["us_email"], (string)
dr_comments_initial["us_username"]));

Response.Write (" on ");
Response.Write (Util.format_db_date(dr_comments_initial["bc_date"]));
Response.Write ("</span></td>");


Response.Write ("</td></tr></table><table border=0><tr><td>");
string s = (string) dr_comments_initial["bc_comment"];
s = Util.format_comment(s);
Response.Write (s);

Response.Write ("</td></tr></table></td></tr>");

}
}


foreach (DataRow dr_comments in ds_comments.Tables[0].Rows)
{

// don't show "initial comment" twice
if ((int) dr_comments["bc_id"] == initial_comment_id)
{
break;
}


Response.Write ("<tr><td>");

if ((string)dr_comments["bc_type"] == "update") // update
{
// posted by
Response.Write ("<span>changed by ");
Response.Write (Util.format_email_username(
id, (string) dr_comments["us_email"], (string)
dr_comments["us_username"]));
Response.Write (" on ");
Response.Write (Util.format_db_date(dr_comments["bc_date"]));
Response.Write ("</span>");
}
else
{
if ((string)dr_comments["bc_type"] == "sent" ) // sent email
{
Response.Write ("<span>email sent to ");
Response.Write (Util.format_email_to(id,
(string)dr_comments["bc_email_to"]));
Response.Write (" by ");
Response.Write (Util.format_email_username(
id, (string) dr_comments["us_email"], (string)
dr_comments["us_username"]));
}
else if ((string)dr_comments["bc_type"] == "received" ) // received email
{
Response.Write ("<span>email received from ");
Response.Write (Util.format_email_from(
(int)dr_comments["bc_id"],
(string)dr_comments["bc_email_from"]));
}
else
{
Response.Write ("<span>comment posted by ");
Response.Write (Util.format_email_username(
id, (string) dr_comments["us_email"], (string)
dr_comments["us_username"]));
}

Response.Write (" on ");
Response.Write (Util.format_db_date(dr_comments["bc_date"]));
Response.Write ("</span>");
}


// the text itself
Response.Write ("<br><br>");
string s = (string) dr_comments["bc_comment"];
s = Util.format_comment(s);
Response.Write (s);
Response.Write ("</td></tr>");

}


Response.Write ("</table>");

if (Util.get_setting("PrintHistory", "1") != "0"
&& Util.get_setting("ShowHistoryWithComments", "0") == "0")
{
Response.Write ("<p>Change History<p><table border=1 cellspacing=0
cellpadding=3>");
sql = @"select
bc_comment [change],
us_username [user],
bc_date [date]
from bug_comments
inner join users on bc_user = us_id
where bc_bug = $id
and bc_type = 'update'
order by bc_date " + Util.get_setting("CommentSortOrder","desc");

sql = sql.Replace("$id", dr["id"].ToString());

DataSet ds3 = dbutil.get_dataset(sql);

foreach (DataRow dr3 in ds3.Tables[0].Rows)
{
Response.Write ("<tr><td>");
Response.Write (dr3["change"]);
Response.Write ("<td>");
Response.Write (dr3["user"]);
Response.Write ("<td>");
Response.Write (Util.format_db_date(dr3["date"]));
Response.Write ("</td></tr>");
}

Response.Write ("</table>");
}

Response.Write ("<div class=align><table
border=0><tr><td></table></div></body>");

}
</script>
Nov 18 '05 #1
1 2069
bidllc wrote:

And when I look at the actual trace, it's the 'can't access
CDO.message' error. I can post it if someone would find it helpful.


I found that if you use the debugger to look into the exception (innerexceptions)
then you might get a more useful answer.
Hans Kesting

PS: If you remove all those empty lines, your posted code would be much
easier to read ...


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2649
by: Martin Meng | last post by:
Set up SMTP / smtp_from variable, as suggested in manual. But the mail() function always return fails. I was trying to use smtp.mail.yahoo.com I wonder if yahoo is somehow blocking smtp...
3
6805
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address...
2
1458
by: VB Programmer | last post by:
I'm encountering an error whenever I try to email people not in my domain. I get this error: The server rejected one or more recipient addresses. The server response was: 550 You must check...
3
1106
by: Justin | last post by:
While trying to send an email using the .net mail class I get this error: "The server rejected one or more recipient addresses. The server response was: 553 sorry, you have not authenticated for...
1
1539
by: nesr235 | last post by:
I am trying to send an email using SMARTHOST. But I am running into problems. Hopefully someone will be able to help. In my web application, I have the following code ... Imports...
5
4856
by: Mark A. Sam | last post by:
Hello, I am sending two emails from the same procedure, one to myself (while testing) and another (a comfirmation) to the user on the website. I was having difficulty finding a relay server to...
3
3854
by: moondaddy | last post by:
I have some code in a web app (asp.net 2.0) and am trying to send an email to 2 different recipients. The first one works and the second one fails. the first email address is of the same domain as...
1
1778
by: creative1 | last post by:
When I test the application I get follwowing error: could not connect to smtp host: connection timeout error can someone please check if I have rigth settings? Where I am wrong here Is IP and...
2
1617
by: wafdenis | last post by:
Hi, I am trying to send html mail() to a number of people at once but it appears as spam in gmail, does not appear in yahoo and appears as jibberish in outlook. I need help in this area as am new...
0
7037
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7080
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6895
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5326
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4770
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4476
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2992
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
176
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.