Link to home
Start Free TrialLog in
Avatar of E=mc2
E=mc2Flag for Canada

asked on

BCC command for VBS script

What is the BCC command used for VBS script when compiling an email?
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Set objEmail = CreateObject( "CDO.Message" )

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

...etc
Avatar of E=mc2

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of E=mc2

ASKER

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