Can anyone tell me how i would format the following ASP line for an email with bold
email_body = email_body & "Full Name: " & fullname & vbcrlf & vbcrlf
I also tried:
email_body = email_body & "<b>Full Name:</b> " & fullname & vbcrlf & vbcrlf
But it didn't work, just showed the tags
The email just showed the bold tags
Sorry the format I want is
Full Name: John Smith
And the ASP code is:
email_body = email_body & "Full Name: " & fullname & vbcrlf & vbcrlf <br />
I tried adding the Bold tags around the Full name, but it didn't format it just showed the actual tags
In order to have bold or other text formatting in an email, you have to make sure that the email is sent as HTML and not plain text. In your case it seems to be sent as plain text. Here are the ways to do it with the common mail components (some code copied from respective documentations):
CDO
objMessage.HTMLBody = "<h1>This is some sample message html.</h1>"
(the property is HTMLBody, not simply Body). Source: http://www.paulsadowski.com/wsh/cdo.htm
ASPEmail
Add:
Mail.IsHTML = True
Source: http://www.aspemail.com/manual_02.html
JMail
Add:
JMail.ContentType = "text/html"
Source: http://www.aspwebpro.com/aspscripts/email/jmail.asp
Set Mail = Server.CreateObject("CDONTS.NewMail")
Mail.from = "me#me.com"
Mail.to = "me#me.com"
Mail.subject = "To Me"
sBody = "<h1>blah blah</h1>"
Mail.bodyFormat = CdoBodyFormatHTML
Mail.body = sBody
Mail.send
Related
I'm working on a rss feed reader and seems so work great.
The only thing that I seem not to get working is to read the image in the feed.
<itunes:image href="http://www.itunes.com/image.jpg"/>
Can anyone help?
This is a part of my code.
For Each objItem in objItems
On Error Resume Next
TheTitle = objItem.selectSingleNode("title").Text
TheLink = objItem.selectSingleNode("image").Text
Theimg = objItem.SelectSingleNode("itunes").Attributes(":image").InnerText
Response.Write "<div class='article'>" &_
"<a href=" & TheLink & ">" & _
"<span>" & Theimg & TheTitle & "</span>" & _
"</a>" & _
"</div>"
Next
Your image address needs to go inside an image tag
Response.Write "<div class=""article"">" &_
"<a href=""" & TheLink & """>" & _
"<img src=""" & Theimg & """ alt=""" & TheTitle & """ />" & _
"</a>" & _
"</div>"
If you're wondering why all the double quotes, see this question
Adding quotes to a string in VBScript
As an aside, if you understand XSL then I find that the best way to handle RSS feeds in Classic ASP is to do a server side XSLT transformation. The ASP looks like this
set xml = Server.CreateObject("Msxml2.DomDocument.6.0")
xml.setProperty "ServerHTTPRequest", true
xml.async = false
xml.validateOnParse = false
xml.load("http://your-rss-feed")
set xsl = Server.CreateObject("Msxml2.DomDocument.6.0")
xsl.load(Server.Mappath("yourxslfile.xsl"))
Response.Write(xml.transformNode(xsl))
set xsl = nothing
set xml = nothing
I am trying to return a link for the given text.
Here is the code:
<%
dim t
t = Request.QueryString("txt")
Response.Write("<a href = \" page2.html \" >" & t & "<\a>")
%>
Can anybody tell me what's wrong with the code?, it is not working.
To escape the " in vbscript, you have to double it. That is use "" for printing ".
Response.Write("<a href = "" page2.html "" >" & t & "<\a>")
Hi im doing a ASP contact form and for some reason i keep getting this.
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/confirmation.asp, line 10
800401f3
I think that theres something wrong with my SMTP, please any help would be grateful.
<%
DIM strEmail, strFirstName, strLastName, strSubject, strComments
strEmail = request.form("Email")
strFirstName = request.form("FirstName")
strLastName = request.form("LastName")
strSubject = request.form("Subject")
strComments = request.form("Comments")
DIM Mailer,strMsgHeader, qryItem, strMsgInfo
Set Mailer = Server.CreateObject("smtpout.secureserver.net")//this line might be wrong.
Mailer.FromName = "Web Designs"
Mailer.FromAddress= "carlos#example.net"
Mailer.ReplyTo = strEmail
Mailer.RemoteHost = "mail.example.net"
Mailer.AddRecipient "", ""
Mailer.Subject = "Online Inquiry"
strMsgHeader = "This mail message was sent from the Online Form" & vbCrLf & vbCrLf
Mailer.BodyText = strMsgHeader & vbCrLf & "Email: " & Request.Form("Email") & _
vbCrLf & "First Name: " & Request.Form("FirstName") & _
vbCrLf & "Last Name: " & Request.Form("LastName") & _
vbCrLf & "Subject: " & Request.Form("Subject") & _
vbCrLf & "Comments: " & Request.Form("Comments")
IF Mailer.SendMail THEN
Response.Write strFirstName & ",<br>"
Response.Write "Your message has been successfully sent."
ELSE
Response.Write "The following error occurred while sending your message: " & Mailer.Response
END IF
%>
It seems you mix up the 'send email library' and your SMTP configuration.
the Mailer should look like
Set Mailer = Server.CreateObject("CDO.Message")
(although this could depend on your IIS version)
To configure your SMTP you should use this object:
Set cdoConfig = CreateObject("CDO.Configuration")
cdoConfig.Fields.Item(cdoSMTPServer) = "smtpout.secureserver.net"
Edit: example code: CDO Classic ASP form not working
I am using this code to send email using classic ASP:
Set oJMail = Server.CreateObject("JMail.SMTPMail")
with oJMail
.Sender = "myemail"
.SenderName = "Me"
.AddRecipient "some email"
.Subject = "some subject"
.Body = "Name: " & fname & " Email:" & email & "Phone: " & phone
end with
oJMail.ServerAddress = "mysmtp:25"
oJMail.Execute
Set oJMail = Nothing
But the server keep throwing this error:
Microsoft JScript compilation error '800a03ec'
Expected ';'
/index.asp, line 108
Set oJMail = Server.CreateObject("JMail.SMTPMail")
----^
Can it be something to do with my page header?
<%# Language="javascript" %>
Yes, that looks like VBScript code, in which case you'd want your page header to have:
<%# Language="VBScript" %>
Of course, this causes problems if the rest of your page is already written in JavaScript.
Dim x As String
x = "http://www.domain.com/aaa/test/default2.aspx?date=" & now.Text & "&tfname=" & p1fname.Text & "&tlname=" & p1lname.Text & "&comp=" & Request.QueryString("comp")
Dim objEmail As New MailMessage()
objEmail.To = "test#email.com"
objEmail.From = "me#test.com"
objEmail.Cc = "test#email.com"
objEmail.Subject = "Test Email"
objEmail.Body = x
SmtpMail.SmtpServer = "mail.domain.com"
Try
SmtpMail.Send(objEmail)
Catch exc As Exception
Response.Write("Send failure: " + exc.ToString())
End Try
When I get the email it comes with
http://www.domain.com/aaa/test/default2.aspx?date=1/13/2011
as a link
and the rest as text
11:39:09 AM&tfname=sadasd&tlname=asd&comp=GWI
Whenever you put a parameter into a query string, you should encode it using System.Web.HttpUtility.UrlEncode to avoid invalid characters going into the URL:
x = "http://www.domain.com/aaa/test/default2.aspx?date=" & HttpUtility.UrlEncode(now.Text) &
"&tfname=" & HttpUtility.UrlEncode(p1fname.Text) &
"&tlname=" & HttpUtility.UrlEncode(p1lname.Text) &
"&comp=" & HttpUtility.UrlEncode(Request.QueryString("comp"))
You cannot have Spaces in the query string, if you need to put spaces, replace it with %20 before appending to the querystring. Although the ideal way to do this is to encrypt and decrpt the text in the querystring.