attaching file problem

Results 1 to 2 of 2

Thread: attaching file problem

  1. #1
    Join Date
    Dec 1969

    Default attaching file problem

    I am having difficulties with sending a mail out to a list of subscribers stored in a database with an attachement of 1Mb.<BR><BR>some subscribers don&#039;t get it, and sometimes the email script reports an error after sending the last email and before ending the script.<BR><BR>Question:- Does the file have to be uploaded to the mail server each time, and then this time lag causes the script to error before mailing out to each email address? Currently there are about 150 on the list, if it is problematic now how can i better do what I am doing for the future with a lrger db of subscribers?<BR><BR>the script is below and I have no problems gettign it to work generally it seems to fail occaisionally, particularly with hotmail accounts, although not recently.<BR><BR>Any advice please?<BR><BR>&#060;!--#include file="../Connections/*******database.asp"--&#062;<BR>&#060;% session("flagged1") = false %&#062;<BR>&#060;%<BR> if session("adminuserid")="" then<BR> Response.Redirect "adminer_ses_login.htm"<BR> end if<BR>%&#062;<BR><BR><BR>&#060;%<BR><BR> dim mainrs<BR>set mainrs = server.CreateObject("adodb.recordset")<BR>mainrs.A ctiveConnection = ********database_STRING<BR> sqlstr = "select * from [newsletter subscribers]"<BR> <BR> mainrs.Open sqlstr, conn<BR> <BR> while not mainrs.EOF<BR><BR> &#039;///////////////////////////////////////<BR> xto = mainrs.Fields("email address")<BR> xfrom = "newsletter@*****.com"<BR> xsubject = request("subject")<BR> xbody = request("letter")<BR> <BR> set imsg = createobject("cdo.message")<BR>set iconf = createobject("cdo.configuration")<BR><BR>Set Flds = iConf.Fields<BR>With Flds<BR>.item("") = 900<BR>.Item("") = 25<BR>.Item("") = 2<BR>.Item("") = "***.********.com"<BR>.Update<BR>End With<BR><BR>With iMsg<BR> Set .Configuration = iConf<BR> .To = xto<BR> .From = xfrom <BR> .CC = ""<BR> .Subject = xsubject<BR> .TextBody = xbody<BR> .AddAttachment "D:websitespostmedata
    ewsletter.pdf"<BR> .fields.update <BR> .Send<BR>End With<BR><BR>set imsg = nothing<BR>set iconf = nothing<BR> &#039;///////////////////////////////////////<BR> mainrs.MoveNext<BR> wend<BR> <BR> Response.Redirect("newsletter.asp?flag=sent")

  2. #2
    Join Date
    Dec 1969

    Default RE: attaching file problem

    You can try to place as much of your code as possible outside the While-Wend loop.<BR><BR>I know it is possible to reuse CDO.Configuration objects, so you can do that only once and use the same configuration object for each mail.<BR><BR>Maybe it is also possible to reuse CDO.Message objects, and only change the To address, like this:<BR><BR><BR>set imsg = createobject("cdo.message")<BR>set iconf = createobject("cdo.configuration")<BR><BR>Set Flds = iConf.Fields<BR>With Flds<BR> .item("") = 900<BR> .Item("") = 25<BR> .Item("") = 2<BR> .Item("") = "***.********.com"<BR> .Update<BR>End With<BR><BR>With iMsg<BR> Set .Configuration = iConf<BR> .From = "newsletter@*****.com" <BR> .CC = ""<BR> .Subject = request("subject")<BR> .TextBody = request("letter")<BR> .AddAttachment "D:websitespostmedata
    ewsletter.pdf"<BR>End With<BR><BR>mainrs.Open sqlstr, conn<BR><BR>while not mainrs.EOF<BR> iMsg.To = mainrs.Fields("email address")<BR> iMsg.Send<BR> mainrs.MoveNext<BR>Wend<BR><BR><BR>I haven&#039;t tried this, but it may be possible.<BR>The advantage will be that the file will be uploaded to the mailserver only once.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts