|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
I have just started work on a system using CDONTS to mail out.
Whilst this is fine on the server, my local development machine is using XP Pro with IIS5.1 installed. Is there a way I can get the functionality of cdonts so that I can test/develop on my local machine, preferably without actually sending any mail to the persons involved. Paul wrote:
> I have just started work on a system using CDONTS to mail out. Here you go: http://www.webthang.co.uk/Tuts/tuts_server/smtp1/smtp1_1.asp> Whilst this is fine on the server, my local development machine is using XP > Pro with IIS5.1 installed. > > Is there a way I can get the functionality of cdonts so that I can > test/develop on my local machine, preferably without actually sending any > mail to the persons involved. You basically download the cdonts.dll and install it on your local machine. I have done that on my developing box and it works perfectly. Steve "Dooza" <steveNO@SPAM.dooza.tv> wrote in message Here you go: http://www.webthang.co.uk/Tuts/tuts_server/smtp1/smtp1_1.aspnews:OgjW0HdLIHA.3940@TK2MSFTNGP05.phx.gbl... Paul wrote: > I have just started work on a system using CDONTS to mail out. > Whilst this is fine on the server, my local development machine is using > XP Pro with IIS5.1 installed. > > Is there a way I can get the functionality of cdonts so that I can > test/develop on my local machine, preferably without actually sending any > mail to the persons involved. You basically download the cdonts.dll and install it on your local machine. I have done that on my developing box and it works perfectly. Steve Great, just finished the install and the page now runs. I even found the emails unsent in the Queue directory. Paul > Great, just finished the install and the page now runs. I even found the Its great when things just work :)> emails unsent in the Queue directory. Steve "Paul" <notha***@btopenworld.com> wrote in message Stop using CDONTS its deprecated. Use CDOSYS instead (CDO.Message etc).news:G6mdnekqn9tHU9vanZ2dnUVZ8s2mnZ2d@bt.com... > I have just started work on a system using CDONTS to mail out. > Whilst this is fine on the server, my local development machine is using XP > Pro with IIS5.1 installed. > > Is there a way I can get the functionality of cdonts so that I can > test/develop on my local machine, preferably without actually sending any > mail to the persons involved. > > WIth IIS5.1 CDOSYS should be already installed on an XP Pro machine. -- Anthony Jones - MVP ASP/ASP.NET On Nov 23, 7:00 am, "Paul" <notha***@btopenworld.com> wrote: Thought you guys would get a kick out of some code I wrote ...> I have just started work on a system using CDONTS to mail out. > Whilst this is fine on the server, my local development machine is using XP > Pro with IIS5.1 installed. > > Is there a way I can get the functionality of cdonts so that I can > test/develop on my local machine, preferably without actually sending any > mail to the persons involved. handler.asp <% '// ======================================================================================================================= '// This handler is only the code displayed below ... the components this handler uses are owned by their respective owners '// This handler allows you to use one subroutine to handle different email components available. '// Only one property (cp_TheComponent) needs to be changed to switch to using a different component. '// ======================================================================================================================== sub cp_EmailHandler(cp_EmailArray) dim cp_TheComponent, cp_SMTPHost, cp_From, cp_ToList, cp_ReplyTo, cp_Subject, cp_Body, cp_Attachments cp_TheComponent = cp_EmailArray(1) cp_SMTPHost = cp_EmailArray(2) cp_From = cp_EmailArray(3) cp_ToList = cp_EmailArray(4) cp_ReplyTo = cp_EmailArray(5) cp_Subject = cp_EmailArray(6) cp_Body = cp_EmailArray(7) cp_Attachments = cp_EmailArray(8) dim cp_MailObj, cp_n, cp_i, cp_arr1, cp_arr2, cp_str1, cp_str2, cp_str3: cp_str1="": cp_str2="": cp_str3="" '// SET MAIL OBJECT TO COMPONENT -- ASPEmail, CDOSys, CDONTS, or ASPMAIL select case cp_TheComponent case "aspemail": Set cp_MailObj = CreateObject("Persits.MailSender") case "cdosys", "cdosys_gate": Set cp_MailObj = CreateObject("CDO.Message") case "cdonts": Set cp_MailObj = CreateObject("CDONTS.NewMail") case "aspmail": Set cp_MailObj = CreateObject("SMTPsvg.Mailer") end select With cp_MailObj '// ===== BEGIN - EXTRA SETTINGS FOR GATE.COM SERVICE - BEGIN ===== if cp_TheComponent = "cdosys_gate" then 'This section provides the configuration information for the remote SMTP server. .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/sendusing") = 2 'Send the message using the network (SMTP over the network). .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/smtpserver") = "127.0.0.1" .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/smtpserverport") = 25 .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/smtpusessl") = False 'Use SSL for the connection (true or False) .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/smtpconnectiontimeout") = 60 .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/smtpauthenticate") = 1 'basic (clear-text) authentication .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/sendusername") = "develo***@coolpier.com" .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ configuration/sendpassword") = "" .Configuration.Fields.Update end if '// ===== END - EXTRA SETTINGS FOR GATE.COM SERVICE - END ===== '// cp_From -- some***@coolpier.com,Your Name --or-- some***@coolpier.com '// cp_ToList -- to,some***@coolpier.com,Their Name;to,anot***@coolpier.com;cc,yetanot***@coolpier.com,Name '// -- notice the above string has sendType,email@address,Name(optional) '// -- sendType can be to, cc, or bcc *comma* email@address *comma* Optional Name ... '// then *semicolon* before the next one, but not one at the end of the string '// cp_ReplyTo -- email address only ... no name select case cp_TheComponent case "aspemail" '// www.persits.com '//from .Host = cp_SMTPHost: cp_arr1 = split(cp_From, ","): .From = cp_arr1(0): .FromName = cp_arr1(ubound(cp_arr1)) '//to cp_arr1 = split(cp_ToList, ";") for cp_n = 0 to ubound(cp_arr1) cp_arr2 = split(cp_arr1(cp_n), ",") select case cp_arr2(0) case "to": .AddAddress cp_arr2(1), cp_arr2(ubound(cp_arr2)) case "cc": .AddCC cp_arr2(1), cp_arr2(ubound(cp_arr2)) case "bcc": .AddBcc cp_arr2(1), cp_arr2(ubound(cp_arr2)) end select next if not cp_ReplyTo = "" then .AddReplyTo cp_ReplyTo case "cdosys", "cdosys_gate" '//from cp_arr1 = split(cp_From, ","): .From = cp_arr1(ubound(cp_arr1)) & " <" & cp_arr1(0) & ">" '//to cp_arr1 = split(cp_ToList, ";") for cp_n = 0 to ubound(cp_arr1) cp_arr2 = split(cp_arr1(cp_n), ",") select case cp_arr2(0) case "to": cp_str1 = cp_str1 & ";" & cp_arr2(ubound(cp_arr2)) & " <" & cp_arr2(1) & ">" case "cc": cp_str2 = cp_str2 & ";" & cp_arr2(ubound(cp_arr2)) & " <" & cp_arr2(1) & ">" case "bcc": cp_str3 = cp_str3 & ";" & cp_arr2(ubound(cp_arr2)) & " <" & cp_arr2(1) & ">" end select next if not cp_str1 = "" then .To = replace("##" & cp_str1, "##;", "") '// replace is removing semicolon from beginning if not cp_str2 = "" then .Cc = replace("##" & cp_str2, "##;", "") if not cp_str3 = "" then .Bcc = replace("##" & cp_str3, "##;", "") if not cp_ReplyTo = "" then .ReplyTo = cp_ReplyTo case "cdonts" '// '//from cp_arr1 = split(cp_From, ","): .From = cp_arr1(ubound(cp_arr1)) & "<" & cp_arr1(0) & ">" '//to cp_arr1 = split(cp_ToList, ";") for cp_n = 0 to ubound(cp_arr1) cp_arr2 = split(cp_arr1(cp_n), ",") select case cp_arr2(0) case "to": cp_str1 = cp_str1 & ";" & cp_arr2(ubound(cp_arr2)) & "<" & cp_arr2(1) & ">" case "cc": cp_str2 = cp_str2 & ";" & cp_arr2(ubound(cp_arr2)) & "<" & cp_arr2(1) & ">" case "bcc": cp_str3 = cp_str3 & ";" & cp_arr2(ubound(cp_arr2)) & "<" & cp_arr2(1) & ">" end select next if not cp_str1 = "" then .To = replace("##" & cp_str1, "##;", "") '// replace is removing semicolon from beginning if not cp_str2 = "" then .Cc = replace("##" & cp_str2, "##;", "") if not cp_str3 = "" then .Bcc = replace("##" & cp_str3, "##;", "") if not cp_ReplyTo = "" then .value("Reply-To") = cp_ReplyTo case "aspmail" '// www.serverobjects.com '//from .RemoteHost = cp_SMTPHost: cp_arr1 = split(cp_From, ","): .FromAddress = cp_arr1(0): .FromName = cp_arr1(ubound(cp_arr1)) '//to cp_arr1 = split(cp_ToList, ";") for cp_n = 0 to ubound(cp_arr1) cp_arr2 = split(cp_arr1(cp_n), ",") select case cp_arr2(0) case "to": .AddRecipient cp_arr2(ubound(cp_arr2)), cp_arr2(1) case "cc": .AddCC cp_arr2(ubound(cp_arr2)), cp_arr2(1) case "bcc": .AddBCC cp_arr2(ubound(cp_arr2)), cp_arr2(1) end select next if not cp_ReplyTo = "" then .ReplyTo = cp_ReplyTo end select '// cp_Subject -- Plain text subject line. '// cp_Body -- HTML or plain text. if HTML, the first 6 characters must be <HTML> ... in caps '// cp_Attachments -- A comma delimited string containing full path to files to be attached select case cp_TheComponent case "aspemail" .Subject = cp_Subject .Body = cp_Body: if left(cp_Body, 6) = "<HTML>" then .IsHTML = true if not cp_Attachments = "" then cp_arr1 = split(cp_Attachments, ",") for cp_n = 0 to ubound(cp_arr1) .AddAttachment cp_arr1(cp_n) next end if case "cdosys", "cdosys_gate" .Subject = cp_Subject .TextBody = "the body" if left(cp_Body, 6) = "<html>" then: .HTMLBody = cp_Body: Else: .TextBody = cp_Body: end if if not cp_Attachments = "" then cp_arr1 = split(cp_Attachments, ",") for cp_n = 0 to ubound(cp_arr1) .AddAttachment cp_arr1(cp_n) next end if case "cdonts" .Subject = cp_Subject .Body = cp_Body: if left(cp_Body, 6) = "<html>" then: .Bodyformat = 0: .Mailformat = 0: end if if not cp_Attachments = "" then cp_arr1 = split(cp_Attachments, ",") for cp_n = 0 to ubound(cp_arr1) .AttachFile cp_arr1(cp_n) next end if case "aspmail" .Subject = cp_Subject .BodyText = cp_Body: if left(cp_Body, 6) = "<html>" then .ContentType = "text/html" if not cp_Attachments = "" then cp_arr1 = split(cp_Attachments, ",") for cp_n = 0 to ubound(cp_arr1) .AddAttachment cp_arr1(cp_n) next end if end select '// SEND MESSAGE select case cp_TheComponent case "aspemail": .Send case "cdosys", "cdosys_gate": .Send case "cdonts": .Send case "aspmail": .SendMail end select end with set cp_MailObj = nothing end sub '// ==================== END COOLPIER.COM's SCRIPT ==================== %> <!-- #include virtual="/handler.asp" --> <% dim myEmailArray(8) myEmailArray(1) = "cdosys" '// cp_TheComponent () myEmailArray(2) = "mail.yourdomain.com" '// cp_SMTPHost () myEmailArray(3) = "CONTACT_T***@yourdomain.com" '// cp_From () myEmailArray(4) = "to,br***@coolpier.com" '// cp_ToList (to,y***@email.com) myEmailArray(5) = "br***@coolpier.com" '// cp_ReplyTo (the reply-to is used for webforms ... where the sender is the website, and you want to be able to reply to the form user's email) myEmailArray(6) = "the email subject in plain text" '// cp_Subject () myEmailArray(7) = "the email body .. html or plain text" '// cp_Body (default is plain text ... to use HTML email, simply be sure that the first 6 characters of your body are the tag ... <HTML> ) myEmailArray(8) = "" '// cp_Attachments (if you wish to send an attachment with your email, include a comma delimited string with the full path of the files you wish to include.) 'call cp_EmailHandler(myEmailArray) %> On Nov 24, 4:06 am, Brynn <coolp***@gmail.com> wrote:
Show quote > On Nov 23, 7:00 am, "Paul" <notha***@btopenworld.com> wrote: BLAH!!!!! Dam new news reader program ... screwed up the formatting of> > > I have just started work on a system using CDONTS to mail out. > > Whilst this is fine on the server, my local development machine is using XP > > Pro with IIS5.1 installed. > > > Is there a way I can get the functionality of cdonts so that I can > > test/develop on my local machine, preferably without actually sending any > > mail to the persons involved. > > Thought you guys would get a kick out of some code I wrote ... > > handler.asp > > <% > '// > ======================================================================================================================= > '// This handler is only the code displayed below ... the components > this handler uses are owned by their respective owners > > '// This handler allows you to use one subroutine to handle different > email components available. > '// Only one property (cp_TheComponent) needs to be changed to switch > to using a different component. > '// > ======================================================================================================================== > > sub cp_EmailHandler(cp_EmailArray) > dim cp_TheComponent, cp_SMTPHost, cp_From, cp_ToList, cp_ReplyTo, > cp_Subject, cp_Body, cp_Attachments > cp_TheComponent = cp_EmailArray(1) > cp_SMTPHost = cp_EmailArray(2) > cp_From = cp_EmailArray(3) > cp_ToList = cp_EmailArray(4) > cp_ReplyTo = cp_EmailArray(5) > cp_Subject = cp_EmailArray(6) > cp_Body = cp_EmailArray(7) > cp_Attachments = cp_EmailArray(8) > > dim cp_MailObj, cp_n, cp_i, cp_arr1, cp_arr2, cp_str1, cp_str2, > cp_str3: cp_str1="": cp_str2="": cp_str3="" > > '// SET MAIL OBJECT TO COMPONENT -- ASPEmail, CDOSys, CDONTS, or > ASPMAIL > select case cp_TheComponent > case "aspemail": Set cp_MailObj = CreateObject("Persits.MailSender") > case "cdosys", "cdosys_gate": Set cp_MailObj = > CreateObject("CDO.Message") > case "cdonts": Set cp_MailObj = CreateObject("CDONTS.NewMail") > case "aspmail": Set cp_MailObj = CreateObject("SMTPsvg.Mailer") > end select > With cp_MailObj > > '// ===== BEGIN - EXTRA SETTINGS FOR GATE.COM SERVICE - BEGIN ===== > if cp_TheComponent = "cdosys_gate" then > 'This section provides the configuration information for the remote > SMTP server. > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/sendusing") = 2 'Send the message using the network > (SMTP over the network). > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/smtpserver") = "127.0.0.1" > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/smtpserverport") = 25 > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/smtpusessl") = False 'Use SSL for the connection (true > or False) > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/smtpconnectiontimeout") = 60 > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/smtpauthenticate") = 1 'basic (clear-text) > authentication > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/sendusername") = "develo***@coolpier.com" > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > configuration/sendpassword") = "" > > .Configuration.Fields.Update > end if > '// ===== END - EXTRA SETTINGS FOR GATE.COM SERVICE - END ===== > > '// cp_From -- some***@coolpier.com,Your Name --or-- > some***@coolpier.com > '// cp_ToList -- to,some***@coolpier.com,Their > Name;to,anot***@coolpier.com;cc,yetanot***@coolpier.com,Name > '// -- notice the above string has > sendType,email@address,Name(optional) > '// -- sendType can be to, cc, or bcc *comma* > email@address *comma* Optional Name ... > '// then *semicolon* before the next one, but not one > at the end of the string > '// cp_ReplyTo -- email address only ... no name > select case cp_TheComponent > case "aspemail" '//www.persits.com > '//from > .Host = cp_SMTPHost: cp_arr1 = split(cp_From, ","): .From = > cp_arr1(0): .FromName = cp_arr1(ubound(cp_arr1)) > '//to > cp_arr1 = split(cp_ToList, ";") > for cp_n = 0 to ubound(cp_arr1) > cp_arr2 = split(cp_arr1(cp_n), ",") > select case cp_arr2(0) > case "to": .AddAddress cp_arr2(1), cp_arr2(ubound(cp_arr2)) > case "cc": .AddCC cp_arr2(1), cp_arr2(ubound(cp_arr2)) > case "bcc": .AddBcc cp_arr2(1), cp_arr2(ubound(cp_arr2)) > end select > next > if not cp_ReplyTo = "" then .AddReplyTo cp_ReplyTo > > case "cdosys", "cdosys_gate" > '//from > cp_arr1 = split(cp_From, ","): .From = cp_arr1(ubound(cp_arr1)) & " > <" & cp_arr1(0) & ">" > '//to > cp_arr1 = split(cp_ToList, ";") > for cp_n = 0 to ubound(cp_arr1) > cp_arr2 = split(cp_arr1(cp_n), ",") > select case cp_arr2(0) > case "to": cp_str1 = cp_str1 & ";" & cp_arr2(ubound(cp_arr2)) & " > <" & cp_arr2(1) & ">" > case "cc": cp_str2 = cp_str2 & ";" & cp_arr2(ubound(cp_arr2)) & " > <" & cp_arr2(1) & ">" > case "bcc": cp_str3 = cp_str3 & ";" & cp_arr2(ubound(cp_arr2)) & > " <" & cp_arr2(1) & ">" > end select > next > if not cp_str1 = "" then .To = replace("##" & cp_str1, "##;", "") > '// replace is removing semicolon from beginning > if not cp_str2 = "" then .Cc = replace("##" & cp_str2, "##;", "") > if not cp_str3 = "" then .Bcc = replace("##" & cp_str3, "##;", "") > if not cp_ReplyTo = "" then .ReplyTo = cp_ReplyTo > > case "cdonts" '// > '//from > cp_arr1 = split(cp_From, ","): .From = cp_arr1(ubound(cp_arr1)) & > "<" & cp_arr1(0) & ">" > '//to > cp_arr1 = split(cp_ToList, ";") > for cp_n = 0 to ubound(cp_arr1) > cp_arr2 = split(cp_arr1(cp_n), ",") > select case cp_arr2(0) > case "to": cp_str1 = cp_str1 & ";" & cp_arr2(ubound(cp_arr2)) & > "<" & cp_arr2(1) & ">" > case "cc": cp_str2 = cp_str2 & ";" & cp_arr2(ubound(cp_arr2)) & > "<" & cp_arr2(1) & ">" > case "bcc": cp_str3 = cp_str3 & ";" & cp_arr2(ubound(cp_arr2)) & > "<" & cp_arr2(1) & ">" > end select > next > if not cp_str1 = "" then .To = replace("##" & cp_str1, "##;", "") > '// replace is removing semicolon from beginning > if not cp_str2 = "" then .Cc = replace("##" & cp_str2, "##;", "") > if not cp_str3 = "" then .Bcc = replace("##" & cp_str3, "##;", "") > if not cp_ReplyTo = "" then .value("Reply-To") = cp_ReplyTo > > case "aspmail" '//www.serverobjects.com > '//from > .RemoteHost = cp_SMTPHost: cp_arr1 = split(cp_From, > ","): .FromAddress = cp_arr1(0): .FromName = cp_arr1(ubound(cp_arr1)) > '//to > cp_arr1 = split(cp_ToList, ";") > for cp_n = 0 to ubound(cp_arr1) > cp_arr2 = split(cp_arr1(cp_n), ",") > select case cp_arr2(0) > case "to": .AddRecipient cp_arr2(ubound(cp_arr2)), cp_arr2(1) > case "cc": .AddCC cp_arr2(ubound(cp_arr2)), cp_arr2(1) > case "bcc": .AddBCC cp_arr2(ubound(cp_arr2)), cp_arr2(1) > end select > next > if not cp_ReplyTo = "" then .ReplyTo = cp_ReplyTo > > end select > > '// cp_Subject -- Plain text subject line. > '// cp_Body -- HTML or plain text. if HTML, the first 6 > characters must be <HTML> ... in caps > '// cp_Attachments -- A comma delimited string containing full path > to files to be attached > select case cp_TheComponent > case "aspemail" > .Subject = cp_Subject > .Body = cp_Body: if left(cp_Body, 6) = "<HTML>" then .IsHTML = true > if not cp_Attachments = "" then > cp_arr1 = split(cp_Attachments, ",") > for cp_n = 0 to ubound(cp_arr1) > .AddAttachment cp_arr1(cp_n) > next > end if > > case "cdosys", "cdosys_gate" > .Subject = cp_Subject > .TextBody = "the body" > if left(cp_Body, 6) = "<html>" then: .HTMLBody = cp_Body: > Else: .TextBody = cp_Body: end if > if not cp_Attachments = "" then > cp_arr1 = split(cp_Attachments, ",") > for cp_n = 0 to ubound(cp_arr1) > .AddAttachment cp_arr1(cp_n) > next > end if > > case "cdonts" > .Subject = cp_Subject > .Body = cp_Body: if left(cp_Body, 6) = "<html>" then: .Bodyformat = > 0: .Mailformat = 0: end if > if not cp_Attachments = "" then > cp_arr1 = split(cp_Attachments, ",") > for cp_n = 0 to ubound(cp_arr1) > .AttachFile cp_arr1(cp_n) > next > end if > > case "aspmail" > .Subject = cp_Subject > .BodyText = cp_Body: if left(cp_Body, 6) = "<html>" > then .ContentType = "text/html" > if not cp_Attachments = "" then > cp_arr1 = split(cp_Attachments, ",") > for cp_n = 0 to ubound(cp_arr1) > .AddAttachment cp_arr1(cp_n) > next > end if > > end select > > '// SEND MESSAGE > select case cp_TheComponent > case "aspemail": .Send > case "cdosys", "cdosys_gate": .Send > case "cdonts": .Send > case "aspmail": .SendMail > end select > > end with > set cp_MailObj = nothing > end sub > > '// ==================== END COOLPIER.COM's SCRIPT > ==================== > %> > > <!-- #include virtual="/handler.asp" --> > > <% > dim myEmailArray(8) > myEmailArray(1) = "cdosys" '// cp_TheComponent () > myEmailArray(2) = "mail.yourdomain.com" '// cp_SMTPHost () > myEmailArray(3) = "CONTACT_T***@yourdomain.com" '// cp_From () > myEmailArray(4) = "to,br***@coolpier.com" '// cp_ToList > (to,y***@email.com) > myEmailArray(5) = "br***@coolpier.com" '// cp_ReplyTo (the reply-to > is used for webforms ... where the sender is the website, and you want > to be able to reply to the form user's email) > myEmailArray(6) = "the email subject in plain text" '// cp_Subject () > myEmailArray(7) = "the email body .. html or plain text" '// cp_Body > (default is plain text ... to use HTML email, simply be sure that the > first 6 characters of your body are the tag ... <HTML> ) > myEmailArray(8) = "" '// cp_Attachments (if you wish to send an > attachment with your email, include a comma delimited string with the > full path of the files you wish to include.) > > 'call cp_EmailHandler(myEmailArray) > % that code!!!! Sorry guys. My apologies ... here is a link ... I placed a webpage up with the code if anyone wants it. http://www.brynncurry.com/brynn/_groups/email_handler/default.asp This actually will handle cdonts, cdosys, aspemail, and aspmail ... I wrote it way back when ... and still give it to friends of mine that use shared hosting and what have you that like to use aspmail or jump around between them. Thanks - I squirrel away such Handlers
Pete(Northolt UK) Brynn wrote: Show quote > On Nov 24, 4:06 am, Brynn <coolp***@gmail.com> wrote: > > On Nov 23, 7:00 am, "Paul" <notha***@btopenworld.com> wrote: > > > > > I have just started work on a system using CDONTS to mail out. > > > Whilst this is fine on the server, my local development machine is using XP > > > Pro with IIS5.1 installed. > > > > > Is there a way I can get the functionality of cdonts so that I can > > > test/develop on my local machine, preferably without actually sending any > > > mail to the persons involved. > > > > Thought you guys would get a kick out of some code I wrote ... > > > > handler.asp > > > > <% > > '// > > ======================================================================================================================= > > '// This handler is only the code displayed below ... the components > > this handler uses are owned by their respective owners > > > > '// This handler allows you to use one subroutine to handle different > > email components available. > > '// Only one property (cp_TheComponent) needs to be changed to switch > > to using a different component. > > '// > > ======================================================================================================================== > > > > sub cp_EmailHandler(cp_EmailArray) > > dim cp_TheComponent, cp_SMTPHost, cp_From, cp_ToList, cp_ReplyTo, > > cp_Subject, cp_Body, cp_Attachments > > cp_TheComponent = cp_EmailArray(1) > > cp_SMTPHost = cp_EmailArray(2) > > cp_From = cp_EmailArray(3) > > cp_ToList = cp_EmailArray(4) > > cp_ReplyTo = cp_EmailArray(5) > > cp_Subject = cp_EmailArray(6) > > cp_Body = cp_EmailArray(7) > > cp_Attachments = cp_EmailArray(8) > > > > dim cp_MailObj, cp_n, cp_i, cp_arr1, cp_arr2, cp_str1, cp_str2, > > cp_str3: cp_str1="": cp_str2="": cp_str3="" > > > > '// SET MAIL OBJECT TO COMPONENT -- ASPEmail, CDOSys, CDONTS, or > > ASPMAIL > > select case cp_TheComponent > > case "aspemail": Set cp_MailObj = CreateObject("Persits.MailSender") > > case "cdosys", "cdosys_gate": Set cp_MailObj = > > CreateObject("CDO.Message") > > case "cdonts": Set cp_MailObj = CreateObject("CDONTS.NewMail") > > case "aspmail": Set cp_MailObj = CreateObject("SMTPsvg.Mailer") > > end select > > With cp_MailObj > > > > '// ===== BEGIN - EXTRA SETTINGS FOR GATE.COM SERVICE - BEGIN ===== > > if cp_TheComponent = "cdosys_gate" then > > 'This section provides the configuration information for the remote > > SMTP server. > > > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/sendusing") = 2 'Send the message using the network > > (SMTP over the network). > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/smtpserver") = "127.0.0.1" > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/smtpserverport") = 25 > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/smtpusessl") = False 'Use SSL for the connection (true > > or False) > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/smtpconnectiontimeout") = 60 > > > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/smtpauthenticate") = 1 'basic (clear-text) > > authentication > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/sendusername") = "develo***@coolpier.com" > > .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/ > > configuration/sendpassword") = "" > > > > .Configuration.Fields.Update > > end if > > '// ===== END - EXTRA SETTINGS FOR GATE.COM SERVICE - END ===== > > > > '// cp_From -- some***@coolpier.com,Your Name --or-- > > some***@coolpier.com > > '// cp_ToList -- to,some***@coolpier.com,Their > > Name;to,anot***@coolpier.com;cc,yetanot***@coolpier.com,Name > > '// -- notice the above string has > > sendType,email@address,Name(optional) > > '// -- sendType can be to, cc, or bcc *comma* > > email@address *comma* Optional Name ... > > '// then *semicolon* before the next one, but not one > > at the end of the string > > '// cp_ReplyTo -- email address only ... no name > > select case cp_TheComponent > > case "aspemail" '//www.persits.com > > '//from > > .Host = cp_SMTPHost: cp_arr1 = split(cp_From, ","): .From = > > cp_arr1(0): .FromName = cp_arr1(ubound(cp_arr1)) > > '//to > > cp_arr1 = split(cp_ToList, ";") > > for cp_n = 0 to ubound(cp_arr1) > > cp_arr2 = split(cp_arr1(cp_n), ",") > > select case cp_arr2(0) > > case "to": .AddAddress cp_arr2(1), cp_arr2(ubound(cp_arr2)) > > case "cc": .AddCC cp_arr2(1), cp_arr2(ubound(cp_arr2)) > > case "bcc": .AddBcc cp_arr2(1), cp_arr2(ubound(cp_arr2)) > > end select > > next > > if not cp_ReplyTo = "" then .AddReplyTo cp_ReplyTo > > > > case "cdosys", "cdosys_gate" > > '//from > > cp_arr1 = split(cp_From, ","): .From = cp_arr1(ubound(cp_arr1)) & " > > <" & cp_arr1(0) & ">" > > '//to > > cp_arr1 = split(cp_ToList, ";") > > for cp_n = 0 to ubound(cp_arr1) > > cp_arr2 = split(cp_arr1(cp_n), ",") > > select case cp_arr2(0) > > case "to": cp_str1 = cp_str1 & ";" & cp_arr2(ubound(cp_arr2)) & " > > <" & cp_arr2(1) & ">" > > case "cc": cp_str2 = cp_str2 & ";" & cp_arr2(ubound(cp_arr2)) & " > > <" & cp_arr2(1) & ">" > > case "bcc": cp_str3 = cp_str3 & ";" & cp_arr2(ubound(cp_arr2)) & > > " <" & cp_arr2(1) & ">" > > end select > > next > > if not cp_str1 = "" then .To = replace("##" & cp_str1, "##;", "") > > '// replace is removing semicolon from beginning > > if not cp_str2 = "" then .Cc = replace("##" & cp_str2, "##;", "") > > if not cp_str3 = "" then .Bcc = replace("##" & cp_str3, "##;", "") > > if not cp_ReplyTo = "" then .ReplyTo = cp_ReplyTo > > > > case "cdonts" '// > > '//from > > cp_arr1 = split(cp_From, ","): .From = cp_arr1(ubound(cp_arr1)) & > > "<" & cp_arr1(0) & ">" > > '//to > > cp_arr1 = split(cp_ToList, ";") > > for cp_n = 0 to ubound(cp_arr1) > > cp_arr2 = split(cp_arr1(cp_n), ",") > > select case cp_arr2(0) > > case "to": cp_str1 = cp_str1 & ";" & cp_arr2(ubound(cp_arr2)) & > > "<" & cp_arr2(1) & ">" > > case "cc": cp_str2 = cp_str2 & ";" & cp_arr2(ubound(cp_arr2)) & > > "<" & cp_arr2(1) & ">" > > case "bcc": cp_str3 = cp_str3 & ";" & cp_arr2(ubound(cp_arr2)) & > > "<" & cp_arr2(1) & ">" > > end select > > next > > if not cp_str1 = "" then .To = replace("##" & cp_str1, "##;", "") > > '// replace is removing semicolon from beginning > > if not cp_str2 = "" then .Cc = replace("##" & cp_str2, "##;", "") > > if not cp_str3 = "" then .Bcc = replace("##" & cp_str3, "##;", "") > > if not cp_ReplyTo = "" then .value("Reply-To") = cp_ReplyTo > > > > case "aspmail" '//www.serverobjects.com > > '//from > > .RemoteHost = cp_SMTPHost: cp_arr1 = split(cp_From, > > ","): .FromAddress = cp_arr1(0): .FromName = cp_arr1(ubound(cp_arr1)) > > '//to > > cp_arr1 = split(cp_ToList, ";") > > for cp_n = 0 to ubound(cp_arr1) > > cp_arr2 = split(cp_arr1(cp_n), ",") > > select case cp_arr2(0) > > case "to": .AddRecipient cp_arr2(ubound(cp_arr2)), cp_arr2(1) > > case "cc": .AddCC cp_arr2(ubound(cp_arr2)), cp_arr2(1) > > case "bcc": .AddBCC cp_arr2(ubound(cp_arr2)), cp_arr2(1) > > end select > > next > > if not cp_ReplyTo = "" then .ReplyTo = cp_ReplyTo > > > > end select > > > > '// cp_Subject -- Plain text subject line. > > '// cp_Body -- HTML or plain text. if HTML, the first 6 > > characters must be <HTML> ... in caps > > '// cp_Attachments -- A comma delimited string containing full path > > to files to be attached > > select case cp_TheComponent > > case "aspemail" > > .Subject = cp_Subject > > .Body = cp_Body: if left(cp_Body, 6) = "<HTML>" then .IsHTML = true > > if not cp_Attachments = "" then > > cp_arr1 = split(cp_Attachments, ",") > > for cp_n = 0 to ubound(cp_arr1) > > .AddAttachment cp_arr1(cp_n) > > next > > end if > > > > case "cdosys", "cdosys_gate" > > .Subject = cp_Subject > > .TextBody = "the body" > > if left(cp_Body, 6) = "<html>" then: .HTMLBody = cp_Body: > > Else: .TextBody = cp_Body: end if > > if not cp_Attachments = "" then > > cp_arr1 = split(cp_Attachments, ",") > > for cp_n = 0 to ubound(cp_arr1) > > .AddAttachment cp_arr1(cp_n) > > next > > end if > > > > case "cdonts" > > .Subject = cp_Subject > > .Body = cp_Body: if left(cp_Body, 6) = "<html>" then: .Bodyformat = > > 0: .Mailformat = 0: end if > > if not cp_Attachments = "" then > > cp_arr1 = split(cp_Attachments, ",") > > for cp_n = 0 to ubound(cp_arr1) > > .AttachFile cp_arr1(cp_n) > > next > > end if > > > > case "aspmail" > > .Subject = cp_Subject > > .BodyText = cp_Body: if left(cp_Body, 6) = "<html>" > > then .ContentType = "text/html" > > if not cp_Attachments = "" then > > cp_arr1 = split(cp_Attachments, ",") > > for cp_n = 0 to ubound(cp_arr1) > > .AddAttachment cp_arr1(cp_n) > > next > > end if > > > > end select > > > > '// SEND MESSAGE > > select case cp_TheComponent > > case "aspemail": .Send > > case "cdosys", "cdosys_gate": .Send > > case "cdonts": .Send > > case "aspmail": .SendMail > > end select > > > > end with > > set cp_MailObj = nothing > > end sub > > > > '// ==================== END COOLPIER.COM's SCRIPT > > ==================== > > %> > > > > <!-- #include virtual="/handler.asp" --> > > > > <% > > dim myEmailArray(8) > > myEmailArray(1) = "cdosys" '// cp_TheComponent () > > myEmailArray(2) = "mail.yourdomain.com" '// cp_SMTPHost () > > myEmailArray(3) = "CONTACT_T***@yourdomain.com" '// cp_From () > > myEmailArray(4) = "to,br***@coolpier.com" '// cp_ToList > > (to,y***@email.com) > > myEmailArray(5) = "br***@coolpier.com" '// cp_ReplyTo (the reply-to > > is used for webforms ... where the sender is the website, and you want > > to be able to reply to the form user's email) > > myEmailArray(6) = "the email subject in plain text" '// cp_Subject () > > myEmailArray(7) = "the email body .. html or plain text" '// cp_Body > > (default is plain text ... to use HTML email, simply be sure that the > > first 6 characters of your body are the tag ... <HTML> ) > > myEmailArray(8) = "" '// cp_Attachments (if you wish to send an > > attachment with your email, include a comma delimited string with the > > full path of the files you wish to include.) > > > > 'call cp_EmailHandler(myEmailArray) > > % > > BLAH!!!!! Dam new news reader program ... screwed up the formatting of > that code!!!! Sorry guys. > > My apologies ... here is a link ... I placed a webpage up with the > code if anyone wants it. > > http://www.brynncurry.com/brynn/_groups/email_handler/default.asp > > This actually will handle cdonts, cdosys, aspemail, and aspmail ... I > wrote it way back when ... and still give it to friends of mine that > use shared hosting and what have you that like to use aspmail or jump > around between them. |
|||||||||||||||||||||||