Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with CDOSYS

Status
Not open for further replies.

Bamarama

Programmer
Dec 29, 2006
49
US
Hey gang.
Hoping you can help me here.
I have a page that sends emails out to clans with tournament information. It works, with one small problem.
It goes out to map specific clans. So if 10 clans are registered on a map, it goes out to those 10 clans. simple enough, and that works.

the problem I have is, it also copies the message 10 times in the email it self. so the receiver would be able to scroll down in the email and see the same message 10 times.
if there is 20 users that the email goes out to, then it would copy itself 20 times in the email. I can't figure out what the problem is here.

here is the code i am using.

Code:
'**************************************************
 'Dimension variables 
 Dim objCDOSYSCon  
 
 'Create the e-mail server object 
 Set objCDOSYSMail = Server.CreateObject("CDO.Message") 
 Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration") 

'Out going SMTP server  
 objCDOSYSCon.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "localhost"   
 
objCDOSYSCon.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL]  = 25

objCDOSYSCon.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2

objCDOSYSCon.Fields("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")[/URL] = 60

objCDOSYSCon.Fields.Update  
  
 'Update the CDOSYS Configuration 
 Set objCDOSYSMail.Configuration = objCDOSYSCon 
 

'*************** get clan information ***********

set emails1 = conn.execute("select clan, email from [table] where map = '" & v_map & "'")
do while not emails1.eof

m_name = trim(emails1.fields.item("clan").value)
m_email = trim(emails1.fields.item("email").value)




objCDOSYSMail.From = "[sender]"

objCDOSYSMail.Bcc = "[director]"

objCDOSYSMail.To = m_email
objCDOSYSMail.Subject = "Tourney "&v_map&" Tournament!"

strMSG = strMSG & "Tournaments By EcK" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "You are being sent this email because of your clans experience on the "&v_map& " map" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "Dear "&v_map& " Maggot;" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "You are officially invited to a "&v_map& " Tournament hosted by the EcK Clan" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "--  Double Elimination Tournament" & VbCrLf
strMSG = strMSG & "--  Format will be "&v_format & VbCrLf
strMSG = strMSG & "--  So pick "&v_format1&" members from your clan that you wish to play." & VbCrLf
strMSG = strMSG & "--  All Team Members must be active in the same Clan" & VbCrLf
strMSG = strMSG & "--  Members do NOT need to sign up, only the clan needs to register on the site." & VbCrLf
strMSG = strMSG & "--  Only 16 Clans can play, so sign up early" & VbCrLf
strMSG = strMSG & "--  Date: " &v_date & " Starting Time "&v_time & VbCrLf
strMSG = strMSG & "--  All teams will use the +EcK+ TeamSpeak Server" & VbCrLf
strMSG = strMSG & "--  EcK has 8 AA Gaming Servers to accommodate 16 Teams" & VbCrLf
strMSG = strMSG & "--  You will have to enter the IP of the server, as well as the PW. You will be given that info in TS." & VbCrLf
strMSG = strMSG & "--  Sign up at [URL unfurl="true"]http://tournamentsbyeck.com/tourney/index_tourney.asp?id="&var1[/URL] & VbCrLf
strMSG = strMSG & "--  All Tournament rules and information are located on The Tourney Web site." & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "Please visit [site] too sign up and get the information on all our " & VbCrLf
strMSG = strMSG & "tournaments for the month of May. All teams must be in TeamSpeak 15 minutes " & VbCrLf
strMSG = strMSG & "before start of the Tournament. Teams will have to check in prior to the start of the " & VbCrLf
strMSG = strMSG & "tournament. Late teams will be dropped for teams on the waiting list.  TeamSpeak " & VbCrLf
strMSG = strMSG & "TeamSPeak Ip is posted on Tourney site. Server IP's will be given prior to match." & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "If you have any questions, please reply to this email, and we will get back to you " & VbCrLf
strMSG = strMSG & "promptly." & VbCrLf
strMSG = strMSG & "" & VbCrLf
strMSG = strMSG & "Yours Truely," & VbCrLf
strMSG = strMSG & "GOL Group (Gaming Organizational Leaders)" & VbCrLf

strMSG = strMSG & "[site]" & VbCrLf
strMSG = strMSG & "" & VbCrLf


objCDOSYSMail.TextBody = strMSG

objCDOSYSMail.Send 

emails1.movenext
loop

'Close the server mail object  
Set objCDOSYSMail = Nothing 
Set objCDOSYSCon = Nothing


Conn.Close
Set Conn = Nothing

i have used this scriptmany MANY times before, but it never acted like this.

any help out there please??

tia
Bam
 
The problem is you are not resetting the variable

strMSG = ""

after the email gets sent. It keeps appending more content.

Right here:

Code:
objCDOSYSMail.TextBody = strMSG

objCDOSYSMail.Send 

[!]strMSG = ""[/!]

emails1.movenext
loop

[monkey][snake] <.
 
so you are saying that by putting a
strMSG = ""

it sets it to nothing, then starts over via the loop?
 
Yes, otherwise it keeps adding onto strMSG after it sends the first e-mail without first clearing the message that had already been sent.

[monkey][snake] <.
 
How about you send one message to multiple recipients?

You could put all of the addresses in the TO line, separating them with a semicolon:
Code:
'top part of code goes here

set emails1 = conn.execute("select clan, email from [table] where map = '" & v_map & "'")

m_email = ""
do while not emails1.eof
  m_email = m_email & trim(emails1("email") & "")
  
  emails1.movenext
  if Not not emails1.eof then
    m_email = m_email & ";"
  end if
loop

'remainder of code goes here
 
interesting!

both ways work, but if i use the way stated by sheco, wont it show all the recipients that received the email when they get the email?? since they are all on the to line?
 
I'm not sure if that matters, but say you have to send emails to 100 ppl, your code will run up to 100 times as fast sending the e-mail as Sheco explained.

[monkey][snake] <.
 
yea,

i understand that. but since this is a secure site, i would rather the server work harder, than to let everyone see everyone's email.

it will only be sending out 20 - 30 per group, once a week, so it shouldn't be that big of a deal.

thanks a million guys, it is much appreciated.

and i want to say thanks to all that take time to help here, on behalf of those who never have the courtesy to say thanks.

 
What if you BCC everyone and put your return address in the TO line?
 
just when i thought i was done... you just PULL me back in..lol

yes, that is an even better idea. should work more efficiently to say the least.

thanks again sheco!!
 
hey sheco,

using the code
Code:
do while not emails1.eof
  m_email = m_email & trim(emails1("email") & "")
  
  emails1.movenext
  if Not not emails1.eof then
    m_email = m_email & ";"
    response.write m_email
  end if
loop

returns the emails without the ; between them.
i did the response.write to troubleshoot why i cas getting an error.
+


i won't respond right away, as I work till 10 tonight...
 
Code:
do while not emails1.eof
  m_email = m_email & trim(emails1("email") & "")
  
  emails1.movenext
  if Not not emails1.eof then
    m_email = m_email & ";"
    response.write m_email
  end if
loop

See where your movenext is?

It is before you add on the ";". Put the emails1.movenext AFTER the end if.

Here's a cleaner version:

Code:
do while not emails1.eof
  m_email = m_email & trim(emails1("email") & ";")
  emails1.movenext
loop
m_email = Left(m_email, (Len(m_email) - 1))



[monkey][snake] <.
 
now that is working. will it matter if there is a space between the

@whatever.com and the ;

like

person@something.com ;something@whatever.com ;

??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top