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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send multiple emails using aspmail

Status
Not open for further replies.

LebronJames

Programmer
Apr 5, 2003
93
How do I send out 4 emails at one time using ASPMAIL SMTPsvg.Mailer?


Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 1"
Mailer.BodyText = "This is email # 1"

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 2"
Mailer.BodyText = "This is email # 2"

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 3"
Mailer.BodyText = "This is email # 3"

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 4"
Mailer.BodyText = "This is email # 4"
 
I would assume you need to send after each email creation, since your hard coding them in, sending after each isn't that big of a deal.
 
as candy man said :

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 1"
Mailer.BodyText = "This is email # 1"
Mailer.Send

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 2"
Mailer.BodyText = "This is email # 2"
Mailer.Send

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 3"
Mailer.BodyText = "This is email # 3"
Mailer.Send

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mailhost.localisp.net""
Mailer.FromAddress = Request("txtEmailAdd")
Mailer.AddRecipient "", Request("txtEmailAdd")
Mailer.Subject = "Email 4"
Mailer.BodyText = "This is email # 4"
Mailer.Send
 
Hi,

I've tried this as well and do not get the desired effect. What I'm trying to do is send 2 emails to 2 different recipients with different sets of info in each. In this case, I want to send a user a "Thank you" message and myself form data the user supplied. My code sets up the thank you message first and the form data second. Only the thank you message is sent. The other is lost.

Any ideas?

Thanks!
 
Here try this....
I think you may be erroring out when you try to recreate the object each time. See below. Also, I kinda cleaned it up for you.


-------------------------
strRemoteHost = "mailhost.localisp.net"
strEmail = Request("txtEmailAdd")
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

Mailer.RemoteHost = strRemoteHost
Mailer.FromAddress = strEmail
Mailer.AddRecipient "", strEmail
Mailer.Subject = "Email 1"
Mailer.BodyText = "This is email # 1"
Mailer.Send

'Don't recreate each time
'Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

Mailer.RemoteHost = strRemoteHost
Mailer.FromAddress = strEmail
Mailer.AddRecipient "", strEmail
Mailer.Subject = "Email 2"
Mailer.BodyText = "This is email # 2"
Mailer.Send

'Don't recreate each time
'Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

Mailer.RemoteHost = strRemoteHost
Mailer.FromAddress = strEmail
Mailer.AddRecipient "", strEmail
Mailer.Subject = "Email 3"
Mailer.BodyText = "This is email # 3"
Mailer.Send

'Don't recreate each time
'Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

Mailer.RemoteHost = strRemoteHost
Mailer.FromAddress = strEmail
Mailer.AddRecipient "", strEmail
Mailer.Subject = "Email 4"
Mailer.BodyText = "This is email # 4"
Mailer.Send
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top