Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_cdo thread: Sending email via a loop


Message #1 by "Mike Leedy" <mleedy@f...> on Mon, 21 Jan 2002 18:21:00
I am trying to send pdf attachments to 10-15 email addresses which are 

each a separate record in a SQL 7 database.  2 go through, but the other 

10 are received back (i'm using Exchange Server) with the following 

message:



Your message did not reach some or all of the intended recipients.



      Subject:	Account 4194247001; Invoice#: 2152613

      Sent:	1/21/2002 11:32 AM



The following recipient(s) could not be reached:



      HDATACTR@o... on 1/21/2002 11:36 AM

            The recipient name is not recognized

	The MTS-ID of the original message is: c=US;a= ;p=First 

Communicat;l=WHEEL0201211635DFPDNS3V

            MSEXCH:IMS:First Communications:AKRON:WHEEL 0 (000C05A6) 

Unknown Recipient





My code is as follows:



<%

Dim orsuser

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



strsql = "Select * from INVEMAIL;" 



orsuser.open strsql, "DSN=Firstcomm;uid=sa"

orsuser.movefirst



Do while not orsuser.EOF

		

	'Send email

	strto = orsuser("curl")

	strfrom = "einvoice@f..."

	attfile = "c:\inetpub\intranet\request\" & orsuser("icomp#")& "_" 

& orsuser("iinv#") & ".pdf"  

	inv = "Account " & orsuser("icust#") & "; Invoice#: " & orsuser

("iinv#")  

	set objmail = server.CreateObject("CDONTS.NewMail")

	objmail.to = lcase(strto)

	objmail.from = lcase(strfrom)

	objmail.subject = inv

	objmail.body = "Attached you will find this month's invoice in the 

amount of $" & orsuser("iinvam") & ", due by " & orsuser("month") & "/" & 

orsuser("day") & "/" & orsuser("year") & ".  Please do not respond to this 

email.  Should you have any questions or comments, please contact our 

Customer Care department." 

	objMail.Attachfile attfile

	objmail.send

	

  orsuser.MoveNext

loop



set objmail=nothing

orsuser.Close

set orsuser=nothing

%>    

<Center>All emails sent!





Any help would be greatly appreciated!



Mike





Message #2 by "David M" <ogwodka@h...> on Mon, 21 Jan 2002 20:58:54 +0000

I have noticed there is a problem with the New Mail object where you cannot 

use the same object for each loop iteration.  Try destroying and recreating 

it with each loop iteration.



>From: "Mike Leedy" <mleedy@f...>

>Reply-To: "ASP CDO" <asp_cdo@p...>

>To: "ASP CDO" <asp_cdo@p...>

>Subject: [asp_cdo] Sending email via a loop

>Date: Mon, 21 Jan 2002 18:21:00

>

>I am trying to send pdf attachments to 10-15 email addresses which are

>each a separate record in a SQL 7 database.  2 go through, but the other

>10 are received back (i'm using Exchange Server) with the following

>message:

>

>Your message did not reach some or all of the intended recipients.

>

>       Subject:	Account 4194247001; Invoice#: 2152613

>       Sent:	1/21/2002 11:32 AM

>

>The following recipient(s) could not be reached:

>

>       HDATACTR@o... on 1/21/2002 11:36 AM

>             The recipient name is not recognized

>	The MTS-ID of the original message is: c=US;a= ;p=First

>Communicat;l=WHEEL0201211635DFPDNS3V

>             MSEXCH:IMS:First Communications:AKRON:WHEEL 0 (000C05A6)

>Unknown Recipient

>

>

>My code is as follows:

>

><%

>Dim orsuser

>Set orsuser=Server.CreateObject("ADODB.Recordset")

>

>strsql = "Select * from INVEMAIL;"

>

>orsuser.open strsql, "DSN=Firstcomm;uid=sa"

>orsuser.movefirst

>

>Do while not orsuser.EOF

>

>	'Send email

>	strto = orsuser("curl")

>	strfrom = "einvoice@f..."

>	attfile = "c:\inetpub\intranet\request\" & orsuser("icomp#")& "_"

>& orsuser("iinv#") & ".pdf"

>	inv = "Account " & orsuser("icust#") & "; Invoice#: " & orsuser

>("iinv#")

>	set objmail = server.CreateObject("CDONTS.NewMail")

>	objmail.to = lcase(strto)

>	objmail.from = lcase(strfrom)

>	objmail.subject = inv

>	objmail.body = "Attached you will find this month's invoice in the

>amount of $" & orsuser("iinvam") & ", due by " & orsuser("month") & "/" &

>orsuser("day") & "/" & orsuser("year") & ".  Please do not respond to this

>email.  Should you have any questions or comments, please contact our

>Customer Care department."

>	objMail.Attachfile attfile

>	objmail.send

>

>   orsuser.MoveNext

>loop

>

>set objmail=nothing

>orsuser.Close

>set orsuser=nothing

>%>

><Center>All emails sent!

>

>

>Any help would be greatly appreciated!

>

>Mike

>

>

>








_________________________________________________________________

Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.




  Return to Index