---
title: "Jmail > CDONTS"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/11707-jmail-cdonts"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "costodia"
published: "2001-09-17T20:16:00.000Z"
updated: "2001-09-20T17:05:00.000Z"
replies: 12
views: 380
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/11707-jmail-cdonts"
---

# Jmail > CDONTS

## #1 — costodia, 2001-09-17T20:16Z

Jag skulle behöva denna kod till Cdonts

```
Set JMail = Server.CreateObject("JMail.SMTPMail")
		JMail.ServerAddress = sMailServer
		JMail.Sender = sMailSender
		JMail.Sendername = sMailSenderName
		JMail.Subject = sSubject
		JMail.AddRecipient sTo
		JMail.Body = sBody
		JMail.Execute
```

 någon som vet var en sådan finns?
Fanns på aspcode.net innan men inte nu längre,
tack på förhand,

Permalänk: https://www.webforum.nu/p/11707

## #2 — spango, 2001-09-17T20:21Z

[Google](http://www.google.com/search?q=cdonts+sample+code&sourceid=mozilla-search) är en utmärkt sökmotor.

Permalänk: https://www.webforum.nu/p/286993

## #3 — icaaq, 2001-09-17T20:24Z

kolla [här](http://www.devguru.com/features/tutorials/cdonts/cdonts.html). :)

Permalänk: https://www.webforum.nu/p/286994

## #4 — costodia, 2001-09-18T07:36Z

Av någon anledningen så hittade jag ändå inte något ställe att byta ut denna kod(jag la till det jag glömde föra gången) 

```
	sub SendMail(sTo, sSubject, sBody)
		'TO DO: Change the mail configuration
		sMailServer = "mail.costodia.com"
		sMailSender = "dev@costodia.com"
		sMailSenderName = "Costodia"
		
		Set CDONTS = Server.CreateObject("CDONTS.SMTPMail")
		CDONTS.ServerAddress = sMailServer
		CDONTS.Sender = sMailSender
		CDONTS.Sendername = sMailSenderName
		CDONTS.Subject = sSubject
		CDONTS.AddRecipient sTo
		CDONTS.Body = sBody
		CDONTS.Execute
	end sub
```

Den artiklen du icaaq tar tyvärr bara upp att skicka ut massmail.
Och den söken på google du spango la in visar inte heller så mycket.
den tar dels upp <http://www.aspalliance.com/Yusuf/Article09.asp>  , på <http://www.allarticles.com/resources/articles/article.asp?id=11>  så skriver de t ex så här 

```
'Declare Variables
Dim CDONTSObj, MessageBody

'Create the CDONTS object
Set CDONTSObj = Server.CreateObject("CDONTS.NewMail")

'To Address
CDONTSObj.To = "info@scriptmate.com"

'From Address
CDONTSObj.From = "you@yoursite.com"

'CC Email Addresses seperated by a comma
CDONTSObj.cc = "support@scriptmate.com,amit@millioncolors.com"

'Your Email Message
MessageBody = "Sending a email using ASP was never so easy ! " 

'Subject of the Email Message
CDONTSObj.Subject = "Send a Email"

'Assigning the value of your message to the Object
CDONTSObj.Body = MessageBody

'Send the email
CDONTSObj.Send

'Set the CDONTS object to nothing
Set CDONTSObj = nothing
```

 men tar tex inte upp hur man ställer in smtp:n, på <http://www.beginnersasp.co.uk/cdonts1.aspåtar>  tar de upp det så här

```
 <%
'declare our variables
Dim strMessage , objCDO
Set objCDO = Server.CreateObject("cdonts.NewMail")
'stick the e-mail address you are sending from in here
objCDO.From = "myaddress@myaddress.com"
'this is the email address you are sending to
objCDO.To = "anotheremail@myaddress.com"
'this is the title of your e-mail message
objCDO.subject = "this is a test message"
'this is your actual message
objCDO.body = " This is your actual message in here"
objCDO.send
%>
```

 verkar fungera(jag fick inte det att funka till mitt formulär, sen hittade jag denna koden 

```
 <%
	'declare variables
	  Dim strTo, strSubject, strBody, strFrom 'Strings for recipient, subject, boby
	  Dim objCDOMail 'The CDO object
	  Dim objRec
	
	'grab the variables from the form
	  strFrom = Request.Form("From")
	  strSubject = Request.Form("subject")
	  strBody = Request.Form("body")

  	  Set objRec = Server.CreateObject ("ADODB.Recordset")

	'open the database
	  objRec.Open "EmailList", strConnect, adOpenKeyset, _
	      adLockReadOnly, adCmdTable
	
	'notify the user that the broadcast has started
	  Response.Write("<h1>Broadcast Starting</h1>")
	
	'loop through the recordset
	  While Not objRec.EOF
		'create a new cdo object
		  Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
		'set its properties
		  objCDOMail.From = strFrom
		  objCDOMail.To = objRec("EMail")
		  objCDOMail.Subject = strSubject
		  objCDOMail.Body = strBody
		'send the mail
		  objCDOMail.Send
		'set the object = nothing
		  Set objCDOMail = Nothing
		'confirm to the user that the mail has been sent
		  Response.Write "Message sent to " & objRec("EMail") & "!<br>" 
		'go to the next record
		  objRec.MoveNext
  	  WEND

	'notify the user that the broadcast has completed
	  Response.Write("<h1>Broadcast Comlete</h1>")
%>
```

 men då får jag felet 

> ADODB.Recordset error '800a0bb9'
>
> Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
>
> /dev/services/sponsorship.asp, line 22

Finns det ingen på Webforum som råkar ha kvar Stefan Holmbergs från ASPCODE.net?, själv verkar han intesvara på några mail alls.

Permalänk: https://www.webforum.nu/p/286995

## #5 — icaaq, 2001-09-18T08:19Z

Vad igentligen är det du vill göra ??

Är det att skicka ett vanligt mail med CDONTS så finns det säkert 200 frågor om detta ämne här på wF ;)

Permalänk: https://www.webforum.nu/p/286996

## #6 — costodia, 2001-09-18T08:37Z

Jo, självklart tittade jag i wf först men jag hittade inte heller här någon lösning som fungerade på mitt form, men ja det är ett helt vanligt mailform jag vill skicka.

Permalänk: https://www.webforum.nu/p/286997

## #7 — icaaq, 2001-09-18T11:51Z

Hur ser ditt formulär ut :q

Permalänk: https://www.webforum.nu/p/286998

## #8 — spango, 2001-09-18T11:57Z

... och framför allt, hur ser rad 122 ut?

Permalänk: https://www.webforum.nu/p/286999

## #9 — icaaq, 2001-09-18T11:58Z

122 ?? vad menar du spango?

Permalänk: https://www.webforum.nu/p/287000

## #10 — costodia, 2001-09-18T12:21Z

Mitt formulär har koden:

```
 sub SendMail(sTo, sSubject, sBody)
'TO DO: Change the mail configuration
sMailServer = "mail.costodia.com"
sMailSender = "dev@costodia.com"
sMailSenderName = "Costodia"

Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = sMailServer
JMail.Sender = sMailSender
JMail.Sendername = sMailSenderName
JMail.Subject = sSubject
JMail.AddRecipient sTo
JMail.Body = sBody
JMail.Execute
```

 sen förskte jag ändra den till detta 

```

sub SendMail(sTo, sSubject, sBody)
'TO DO: Change the mail configuration
sMailServer = "mail.costodia.com"
sMailSender = "dev@costodia.com"
sMailSenderName = "Costodia"

Set objMailer = CreateObject("CDONTS.NewMail")
	objMailer.From = strFromEmail
	objMailer.To = strEmail
	objMailer.Subject = strSubject
	objMailer.Body= strBody
	objMailer.Send
	Set objMailer = Nothing
```

 och det gick bra(det komemr inte något felmeddelande längre utan jag kommer till tack-sidan) men där kommer inget mail i min mailbox.

Hela koden till sidan ser ut så här:

```
<%
	bDontCount = False
	sPageTitle = "2eNetWorX - Sponsorship"
	bAdminOnly = False
	lSubjectID = 0
	sTitleBar = "/dev :: <a href=""/dev/index.asp"">home</a> :: services :: sponsorship"

	sub SendMail(sTo, sSubject, sBody)
		'TO DO: Change the mail configuration
		sMailServer = "mail.costodia.com"
		sMailSender = "dev@costodia.com"
		sMailSenderName = "2eNetWorX"
		
		Set objMailer = CreateObject("CDONTS.NewMail")
		objMailer.From = strFromEmail
		objMailer.To = strEmail
		objMailer.Subject = strSubject
		objMailer.Body= strBody
		objMailer.Send
		Set objMailer = Nothing 
	end sub
	
	bErr = False
	if request("cmdSend") <> "" then
		sName = request("txtName")
		sCompany = request("txtCompany")
		sEmail = request("txtEmail")
		sComments = request("txtComments")
		if sName = "" then
			sErr = "Please specify your name."
			bErr = True
		end if

		if len(sEmail) < 6 then
			sErr = "Please specify a correct email."
			bErr = True
		end if
		
		if (instr(sEmail, "@") = 0) or (instr(sEmail,".")=0) then
			sErr = "Please specify a correct email."
			bErr = True
		end if
		
		if not bErr then
			'TO DO : Change the email
			sSponsorEmail = "dev@costodia.com"
			sSubject = "2eNetWorX Sponsorship Inquiry"
			sBody = 		"Name : " & sName & vbCrLf
			sBody = sBody & "Company : " & sCompany & vbCrLf
			sBody = sBody & "Email : " & sEmail & vbCrLf
			sBody = sBody & "Comments : "  & vbCrLf
			sBody = sBody & sComments & vbcrlf & vbcrlf
			sBody = sBody & "Date/Time: " & now & vbcrlf & vbcrlf
			sBody = sBody & "User :" & session("devUserName") & vbcrlf & vbcrlf
			sBody = sBody & "Session :" & session.SessionID & vbcrlf & vbcrlf
			sBody = sBody & "Remote IP : " & Request.ServerVariables("REMOTE_ADDR")
			SendMail sSponsorEmail, sSubject, sBody
			%>
			<!--#include virtual="/dev/_header.asp"-->			
			<br><br>
			<p class="smallerheader">
			Thank you, <br>
			Our representatives will contact you as soon as possible.
			</p>
			<p class="smallertext">
			You may go back to the <a href="/dev/index.asp">main page</a> now.
			</p>
			<!--#include virtual="/dev/_footer.asp"-->			
			<%
			response.end
		end if
	end if

%>	
<!--#include virtual="/dev/_header.asp"-->
	

<br>
<p class="smallaction">
	Sponsorship Relations with 2eNetWorX OpenSource Projects
</p>
<% if sErr = "" then %>
<p class="smallertext">
2eNetWorX is an <a href="/dev/articles/opensource.asp">OpenSource</a>
Projects site which directly targets <strong>developers</strong>
and site <strong>admins</strong>.<br><br>

If you would like to discuss about sponsorship opportunities
please fill the following form. Our representatives will contact
you as soon as possible.

<br>
<% 
	else
		response.write "<p class=""smallerheader"">" & sErr & "</p>"
	end if
%>
<br>
<form action="sponsorship.asp?send=1" method="post">
<table border=0>
	<tr>
		<td class="smallerheader">Your Name</td>
		<td><input type="text" name="txtName" class="tbflat" value="<%=sName%>"></td>
	</tr>
	<tr>
		<td class="smallerheader">Company</td>
		<td><input type="text" name="txtCompany" class="tbflat" value="<%=sCompany%>"></td>
	</tr>
	<tr>
		<td class="smallerheader">Email</td>
		<td><input type="text" name="txtEmail" class="tbflat" value="<%=sEmail%>"></td>
	</tr>
	<tr>
		<td class="smallerheader">Comments</td>
		<td><textarea cols=40 rows=5 name="txtComments" class="tbflat"><%=sComments%></textarea></td>
	</tr>
	<tr>
		<td></td>
		<td><input type="submit" name="cmdSend" value=" Send " class="cmdflat"></td>
	</tr>
</table>
</form>

<br><br>

			
<!--#include virtual="/dev/_footer.asp"-->
```

 .

Rad 122 på den gamla sidan såg ut så hät

```
	else
```

 men den har jag som sagt inte kvar. 
om ni är intresserade av att testa scriptet så ligger det ute på <http://costodia.com/dev/services/sponsorship.asp>

Permalänk: https://www.webforum.nu/p/287001

## #11 — icaaq, 2001-09-18T13:58Z

Denna rad:

```
SendMail sSponsorEmail, sSubject, sBody
```

stämmer inte överens med:

```
sub SendMail(sTo, sSubject, sBody)
```

Och sen måste alla mailadresser vara korrekta och ha en mottagare :)

Permalänk: https://www.webforum.nu/p/287002

## #12 — costodia, 2001-09-18T16:21Z

Tack, jag har ändrat det, fast tyvärr verkar det fortfarande inte fungera (jag sTo, sSubject, sBody till sSponsorEmail, sSubject, sBody
efter det att du skickat ditt meddelande till wf och det har fortfarande inte kommit fram.

Permalänk: https://www.webforum.nu/p/287003

## #13 — costodia, 2001-09-20T17:05Z

Jag löste tyvärr inte problemet, däremot så hade jag ett annat problem på <http://cgi.webforum.nu/wf/Forum11/HTML/006389.html>  som jag löste med din url, så tack så mycket icaaq

Permalänk: https://www.webforum.nu/p/287004

---

Tråden på webben: https://www.webforum.nu/amne/asp/11707-jmail-cdonts
