Sending Multiple Emails at ONCE

xiaoxiao2021-03-06  134

Just like setting up emailing from a form, in general, is not difficult, neither is sending emails to multiple people at the same time First, we need to dimension a variable called 'MyVar':. To hold all the email addresses in a string :

Dim myvar as string

In in Inline Coding, this Would Be Placed Inside The Script Tag, But Outside Any Sub OR Function.

Next We need to set up the BCC Field, Grabbing all the emails from a database field caled (surprise!) 'Email':

DIM mysql as string = "SELECT Email from YourTablename"

DIM MyConn as SqlConnection = New SqlConnection (ConfigurationSettings.AppSettings ("URAPPString"))

Dim Objdr As SqldataReader

DIM CMD AS New Sqlcommand (MySQL, MyConn)

Myconn.open ()

Objdr = cmd.executeReader (System.Data.commandbehavior.closeConnection)

Myvar = ""

While objdr.read ()

MYVAR = Objdr ("email") & ";"

End while

Myvar = myvar.substring (0, (MyVar.Length-1)))

THE LAST LINE MRELY Removes the Semi-Colon from the end. Will naturally be placed there t to the line inside

While section.

You Might Want To Check Out Another Tutorial Here, Called 'Emailing Form Results'. It Goes over Much of this Next Section Also.

Dim Objemail As New MailMessage

Objemail.to = "news@yourdomain.com"

Objemail.From = "You@yourdomain.com"

Objemail.bcc = myvar

Objemail.subject = "this is my subject"

Objemail.body = "Put Text or a variable which represents the text - here"

Objemail.bodyFormat = mailformat.text

SMTPMAIL.SMTPSERVER = "mail.yourdomain.com"

SMTPMAIL.SEND (Objemail)

The main sections that needs addressing here are the BCC field, the BODY field, and the TO field. For most, the TO field will be fairly trivial. You do not need any of the people in the email addresses for this one. I usually use a mail back to me, in order to be sure the email actually went out. in the BCC field, you see that the list of emails in the 'MyVar' variable goes here, without double quotes surrounding it, since it's a variable and not an explicit email address. The same goes for the BODY section. If you wanted to define a section of text, and assign it to a variable, before this block of code, then, you would merely put the variable name there, without .

Hopefully, this Takes a little mystery out of the whole 'sending multiple emails at The Same Time' Scenario.

转载请注明原文地址:https://www.9cbs.com/read-127192.html

New Post(0)