Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JMAIL problem

Enthusiast ,
Feb 07, 2008 Feb 07, 2008
I have adapted some old CDONTS code that I use in order to send emails via web forms, but for some reason the code below is kicking up an error.

<%
Dim strBody
Dim strCustBody
Dim strServer
Dim strSMTPServer

strServer = Replace(request.servervariables("SERVER_NAME"),"www.","")

strSMTPServer = "smtp." & strServer

Set objMail = Server.CreateObject("JMail.Message")
objMail.AddRecipient "info@website.com"
objMail.Subject = "Contact via website from " & Request.Form("name")
objMail.From = Request.Form("email")

' Creating the body here
strBody = strBody & vbCrLf & "Date & Time Submitted:" & Date() + Time()
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
strBody = strBody & vbCrLf & "User details:"
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Name: " & Request.Form("name")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Address:"
strBody = strBody & vbCrLf & Request.Form("address")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "Telephone: " & Request.Form("tel")
strBody = strBody & vbCrLf & "Mobile: " & Request.Form("mobile")
strBody = strBody & vbCrLf & "Email: " & Request.Form("email")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"
strBody = strBody & vbCrLf & "User wrote:"
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "" & Request.Form("query")
strBody = strBody & vbCrLf & " "
strBody = strBody & vbCrLf & "--------------------------------------------"

objMail.Body = strBody

if not objMail.Send(strSMTPServer) then
Response.write "<pre>" & msg.log & "</pre>"
end if

Set objMail = Nothing


Set objCustMail = Server.CreateObject("JMail.Message")

objCustMail.AddRecipient Request.Form("email")
objCustMail.Subject = "Thank you for taking the tie to contact us"
objCustMail.from = "info@website.com"

'Creating customer body here
strCustBody = strCustBody & vbCrLf & "Dear: " & Request.Form("name").
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "Thank you for getting in touch."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "You wrote: "
strCustBody = strCustBody & vbCrLf & "" & Request.Form("query").
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "We will respond to you as soon as we can."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "Kindest regards."
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "The team"
strCustBody = strCustBody & vbCrLf & " "
strCustBody = strCustBody & vbCrLf & "--------------------------------------------"
strCustBody = strCustBody & vbCrLf & "Subscription submitted:" & Date() + Time()

objCustMail.Body = strCustBody

if not objCustMail.Send(strSMTPServer) then
Response.write "<pre>" & msg.log & "</pre>"
end if

Set objCustMail = Nothing
%>


If I remove the second part that goes to the customer, then the send email page works and I receive an email. Why is this happening?

Also, AddRecipient works, but AddRecipientCC and AddRecipientBCC do not work. Again, why is this so?

Thanks

Mat
TOPICS
Server side applications
293
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 07, 2008 Feb 07, 2008
LATEST
The period here is probably causing the error:

strCustBody = strCustBody & vbCrLf & "Dear: " & Request.Form("name").

If you want a period there you will need to do something like this:

strCustBody = strCustBody & vbCrLf & "Dear: " & Request.Form("name") & "."

These shoud work:

objMail.AddRecipientBCC "someemail@somewhere.com"
objMail.AddRecipientCC "otheremail@somewhere.com"

http://www.dimac.net/Products/w3JMail/Manuals/w3JMail45Manual.pdf


--
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com


"matthew stuart" <webforumsuser@macromedia.com> wrote in message
news:fof3b7$cne$1@forums.macromedia.com...
>I have adapted some old CDONTS code that I use in order to send emails via
>web
> forms, but for some reason the code below is kicking up an error. <% Dim
> strBody Dim strCustBody Dim strServer Dim strSMTPServer strServer =
> Replace(request.servervariables('SERVER_NAME'),'www.','') strSMTPServer =
> 'smtp.' & strServer Set objMail =
> Server.CreateObject('JMail.Message')
> objMail.AddRecipient 'info@website.com' objMail.Subject = 'Contact via
> website from ' & Request.Form('name') objMail.From =
> Request.Form('email') ' Creating the body here strBody = strBody
> &
> vbCrLf & 'Date & Time Submitted:' & Date() + Time() strBody
> =
> strBody & vbCrLf & ' ' strBody = strBody & vbCrLf &
> '--------------------------------------------' strBody = strBody &
> vbCrLf
> & 'User details:' strBody = strBody & vbCrLf & ' '
> strBody =
> strBody & vbCrLf & 'Name: ' & Request.Form('name') strBody =
> strBody & vbCrLf & ' ' strBody = strBody & vbCrLf &
> 'Address:' strBody = strBody & vbCrLf & Request.Form('address')
> strBody = strBody & vbCrLf & ' ' strBody = strBody & vbCrLf
> & 'Telephone: ' & Request.Form('tel') strBody = strBody &
> vbCrLf
> & 'Mobile: ' & Request.Form('mobile') strBody = strBody &
> vbCrLf
> & 'Email: ' & Request.Form('email') strBody = strBody &
> vbCrLf
> & ' ' strBody = strBody & vbCrLf &
> '--------------------------------------------' strBody = strBody &
> vbCrLf
> & 'User wrote:' strBody = strBody & vbCrLf & ' ' strBody
> =
> strBody & vbCrLf & '' & Request.Form('query') strBody =
> strBody
> & vbCrLf & ' ' strBody = strBody & vbCrLf &
> '--------------------------------------------' objMail.Body = strBody
> if
> not objMail.Send(strSMTPServer) then Response.write '<pre>' & msg.log
> & '</pre>' end if Set objMail = Nothing Set objCustMail =
> Server.CreateObject('JMail.Message') objCustMail.AddRecipient
> Request.Form('email') objCustMail.Subject = 'Thank you for taking the
> tie to
> contact us' objCustMail.from = 'info@website.com' 'Creating
> customer
> body here strCustBody = strCustBody & vbCrLf & 'Dear: ' &
> Request.Form('name'). strCustBody = strCustBody & vbCrLf & ' '
> strCustBody = strCustBody & vbCrLf & 'Thank you for getting in
> touch.'
> strCustBody = strCustBody & vbCrLf & ' ' strCustBody =
> strCustBody
> & vbCrLf & 'You wrote: ' strCustBody = strCustBody & vbCrLf
> &
> '' & Request.Form('query'). strCustBody = strCustBody & vbCrLf
> &
> ' ' strCustBody = strCustBody & vbCrLf & 'We will respond to
> you as
> soon as we can.' strCustBody = strCustBody & vbCrLf & ' '
> strCustBody = strCustBody & vbCrLf & 'Kindest regards.'
> strCustBody =
> strCustBody & vbCrLf & ' ' strCustBody = strCustBody &
> vbCrLf
> & 'The team' strCustBody = strCustBody & vbCrLf & ' '
> strCustBody = strCustBody & vbCrLf &
> '--------------------------------------------' strCustBody = strCustBody
> & vbCrLf & 'Subscription submitted:' & Date() + Time()
> objCustMail.Body = strCustBody if not objCustMail.Send(strSMTPServer)
> then
> Response.write '<pre>' & msg.log & '</pre>' end if Set
> objCustMail = Nothing %> If I remove the second part that goes to the
> customer, then the send email page works and I receive an email. Why is
> this
> happening? Also, AddRecipient works, but AddRecipientCC and
> AddRecipientBCC do
> not work. Again, why is this so? Thanks Mat
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines