Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 686

working with files and variables

$
0
0
ok so im not sure how this is done I only have a basic understanding of the code.
what i have written is a macro system inside open office and in this macro system it calls to vbs to send an email with an attachment.
Code:

dim attachment
dim subject

attachment = WScript.Arguments.Item(0)
'msgbox attachment,vbInformation
subject = WScript.Arguments.Item(1)
'msgbox subject, vbInformation
'MSGBOX "BREAK"


Set emailObj      = CreateObject("CDO.Message")
emailObj.From    = "from@email.com"
emailObj.To      = "to1@email.com, to2@email.com, 23@email.com, to4@email.com,to5@email.com"
emailObj.Subject  = "subject" & Subject
emailObj.TextBody = "text" & SUBJECT

emailObj.AddAttachment attachment

Set emailConfig = emailObj.Configuration

emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpout.server.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "username"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "password"
emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "EMAIL SENT"

my issue I'm having is people come and go and passwords change so i have to edit the vbs file on 5 computers. what i would like to do is make a simple vbs script that will search the file c:\batch\mailto.vbs for emailObj.To = and store everything inside the "" to emails and then search for emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = and store the "" to password
after that is completed ill need to display a message box to the user asking for a new list of emails and then asking for a new password and then take the user input and replace it in the file
so far I have this code
Code:

Dim Answer
Dim Question
Dim prompt1
Dim title1
dim emailto
Dim prompt2
Dim title2
Dim emailnew
dim password

'fine emailto in file


prompt1 = "Please enter the new email list comma seperating emails."
title1 = "New emails"
'emailto = default responce so users can edit the previous emails.
prompt2 = "Please enter the new password."
title2 = "New password"


    Question = "Did you need to edit the emails?"

    Answer = MsgBox(Question, vbYesNo, "")

    If Answer = vbyes Then
        emailnew = InputBox(prompt1, title1, emailto)
    Else
    End If

        Question = "Did you need to edit the password?"
    Answer = MsgBox(Question, vbYesNo, "")
    If Answer = vbyes Then
        password = InputBox(prompt2, title2, "newpassword")
    Else
    End If



'replace emailto in file


Viewing all articles
Browse latest Browse all 686

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>