BCC command for VBS script

Member_2_5306354
Member_2_5306354 used Ask the Experts™
on
What is the BCC command used for VBS script when compiling an email?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Paul MacDonaldDirector, Information Systems

Commented:
Set objEmail = CreateObject( "CDO.Message" )

   With objEmail
        .From     = myFrom
        .To       = myTo
        .Cc     = myCC
         .Bcc    = myBCC
        .Subject  = mySubject
        .TextBody = myTextBody
        .HTMLBody = myHTMLBody

...etc

Author

Commented:
Thanks, so how would I modify this code to fit that in?

SubjectDate = InputBox("Date to be added to the subject:", "Enter date")
MailTo = "email1@gmail.com"
From = "mainemail@someprovider.com"
Subject = "This is a test " & SubjectDate
Body = "Hi, This is an VBScript to send email, Regards, User."
Username = "mainemail@someprovider.com"
Password = "passwordhere"
Email MailTo, From, Subject, Body, Username, Password

Sub Email (MailTo, From, Subject, Body, Username, Password)
 Set objMessage = CreateObject("CDO.Message")
 With objMessage
  .Subject = Subject
  .From = From
  .To = MailTo
  .TextBody = Body
 End With
 With objMessage.Configuration.Fields
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mainemail@someprovider.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwordhere"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
      .Update
      End With
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objFolder = objFSO.GetFolder("C:\Attachment\")
      Set colFiles = objFolder.Files
      For Each objFile in colFiles
            objMessage.AddAttachment objFile.Path
      Next
      objMessage.Send
End Sub
IT / Software Engineering Consultant
Top Expert 2016
Commented:
Try this:

SubjectDate = InputBox("Date to be added to the subject:", "Enter date")
MailTo = "email1@gmail.com"
From = "mainemail@someprovider.com"
Subject = "This is a test " & SubjectDate
Body = "Hi, This is an VBScript to send email, Regards, User."
Username = "mainemail@someprovider.com"
Password = "passwordhere"
BCC = "email2@gmail.com"

Email MailTo, BCC, From, Subject, Body, Username, Password

Sub Email (MailTo, BCC, From, Subject, Body, Username, Password)
 Set objMessage = CreateObject("CDO.Message")
 With objMessage
  .Subject = Subject
  .From = From
  .To = MailTo
  .BCC = BCC
  .TextBody = Body
 End With
 With objMessage.Configuration.Fields
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mainemail@someprovider.com"
      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwordhere"
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
      .Update
      End With
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objFolder = objFSO.GetFolder("C:\Attachment\")
      Set colFiles = objFolder.Files
      For Each objFile in colFiles
            objMessage.AddAttachment objFile.Path
      Next
      objMessage.Send
End Sub

Open in new window


»bp

Author

Commented:
Thanks so much for that solution Bill, very much appreciated.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial