I am trying to send an email from a VBscript, outbound
thru an SMTP server. My SMTP wants logon validation and I
have not found how to do that yet! If I use MAPI and
reference my 'Profile' which contains the login
credentials then Outlook cries foul thinking my script is
a virus trying to hijak my email account!

How do I pass credentials from the script to send the
email w/o getting frisked by outlook's security?

Re: Sending email from VBS thru SMTP? by Bryan

Bryan
Thu Oct 23 18:50:37 CDT 2003

I don't think you will accomplish this without installing a SMTP server
locally (ie. IIS) or using a third party component. The reason it "cries
foul" is because we have criticized M$ for years about the lack of security
in letting any ole Joe send email through outlooks profile without notifying
someone.

Bryan Martin


"Bryan Kramer" <bryanekramer@msn.com> wrote in message
news:03e101c399a9$adcdbc10$a401280a@phx.gbl...
> I am trying to send an email from a VBscript, outbound
> thru an SMTP server. My SMTP wants logon validation and I
> have not found how to do that yet! If I use MAPI and
> reference my 'Profile' which contains the login
> credentials then Outlook cries foul thinking my script is
> a virus trying to hijak my email account!
>
> How do I pass credentials from the script to send the
> email w/o getting frisked by outlook's security?
>



Re: Sending email from VBS thru SMTP? by TDM

TDM
Fri Oct 24 12:29:35 CDT 2003


Bryan,

I have a mail script that I use and it seems to me that it works
with authentication but I have not testes/used it lately. Here is
the function from my script that actually sends the mail, give it
a wack and see if it helps. I have no way of testing it right now.

Change the network stuff and see where it gets you.

TDM



Function sendMail(sSubject, sRecipient, sMessageBody, sAttachent)
'This function actaully sends the mail. Various different things
'you can do, see commented descriptions.
Dim iMsg 'as Object
Dim iConf 'as Object
Dim Flds 'as Collection

Const cdoSendUsingMethod =
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServerName =
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSendUserName =
"http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword =
"http://schemas.microsoft.com/cdo/configuration/sendpassword"
Const cdoURLProxyServer =
"http://schemas.microsoft.com/cdo/configuration/urlproxyserver"
Const cdoURLProxyBypass =
"http://schemas.microsoft.com/cdo/configuration/urlproxybypass"
Const cdoSMTPAuthenticate =
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoURLGetLatestVersion =
"http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion"
Const cdoSMTPConnectionTimeout =
"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServerName) = "mail.domain.com"
.Item(cdoSMTPConnectionTimeout) = 10 ' quick timeout
.Item(cdoSMTPAuthenticate) = cdoBasic
'lines below only if your SMTP gateway requires authentication, most do
.Item(cdoSendUserName) = "username"
.Item(cdoSendPassword) = "password"
'lines below only if sending through a proxy server, not likely Harold but
just in case
'.Item(cdoURLProxyServer) = "web-proxy:80"
'.Item(cdoURLProxyBypass) = "<local>"
'.Item(cdoURLGetLatestVersion) = True
.Update
End With

With iMsg
Set .Configuration = iConf
.To = """Recip A"" <" & sRecipient & ">"
.From = """From MyName"" <myname@mail.com>"
.Subject = sSubject
.TextBody = sMessageBody
'lines below only if you want to insert a web page.
'.CreateMHTMLBody "http://www.microsoft.com"
If sAttachment <> "" Then
.AddAttachment sAttachment
End If
.Send
End With

Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

End Function



"Bryan Kramer" <bryanekramer@msn.com> wrote in message
news:03e101c399a9$adcdbc10$a401280a@phx.gbl...
> I am trying to send an email from a VBscript, outbound
> thru an SMTP server. My SMTP wants logon validation and I
> have not found how to do that yet! If I use MAPI and
> reference my 'Profile' which contains the login
> credentials then Outlook cries foul thinking my script is
> a virus trying to hijak my email account!
>
> How do I pass credentials from the script to send the
> email w/o getting frisked by outlook's security?
>



Re: Sending email from VBS thru SMTP? by noone

noone
Sun Nov 09 17:44:43 CST 2003

I use this script to invoke outlook and send messages contained in plain txt files in the
same directory as the script itself. it uses current outlook settings. I commented out the
code in something that was expected to be english. It works on my company account that
requires imap validation.
The first line of the txt file should contain the address of the destination.
The second is the subject.
The third till the eof will be the body.

Try if you can get something useful from this.
Giovanni.

'<%
'Outlook SendMail.vbs
'Versione VBS di un programma già in Visual Basic 5, già modificato
'per l'uso con un oggetto COM e ora per appoggiarsi al modello ad oggetti
'di Microsoft Outlook
'Nella cartella corrente ci sono dei files txt contenenti messaggi di
'posta elettronica. Le prime righe di ogni file contengono rispettivamente :
'1) Indirizzo e-mail del destinatario
'2) Oggetto del messaggio.
'Le righe successive contengono il corpo del messaggio.
'Il programma utilizza l'oggetto COM di Outlook (non express)
'Apre ogni file e se è un messaggio (la prima riga contiene una "@"), lo invia.
'[c] Cenati Giovanni 08.06.02 nnever@katamail.com
'Modificato 19.09.03 per outlook
'This script looks for txt files in current (script) directory and
'if they are message files (with a valid e-mail address in the first line)
'sends the message using outlook (not express).
'The txt file must contain:
'In first line a valid e-mail address of the recipient
'In the second line the subject of the message
'From the third line to the end of file, the body of the message.

dim fso 'as filesystemobject
dim objOL 'as Outlook application
dim CartellaPosta
'oggetto directory dove ci sono i messaggi in formato testo
'Directory where to look for the messages.
dim Messaggi
'collezione di files in CartellaPosta. Collection of files in the folder.
dim FileMsg
'oggetto file trovato in CartellaPosta. Single file object in the folder
dim Messaggio
'file aperto in lettura contenente l'E-Mail. File openend to read the message
dim ContaMail
'numero di messaggi e-mail spediti. Number of sent e-Mails

'Crea istanza agli oggetti necessari al programma
'Creates needed objects
set fso = CreateObject("Scripting.FileSystemObject")
Set objOL = CreateObject("Outlook.Application")

'Ottiene la directory dove è situato script
'Retrieves script directory
ScriptFullName =wscript.ScriptFullName
CurrentPath = Left(ScriptFullName, InStrRev(scriptfullname, "\")-1)

'Recupera tutti i files della directory
'Sets folder where to look for messages and reads all files
set CartellaPosta = fso.GetFolder(CurrentPath)
Set Messaggi = CartellaPosta.Files

For Each FileMsg in Messaggi 'Processa ogni file della cartella
if ucase(right(FileMsg,4))=".TXT" then
'se è un txt... If it's a txt...
Set f = fso.GetFile(FileMsg) 'Ne recupera il nome
Set Messaggio = f.OpenAsTextStream 'Apre il file
'Legge le righe del file contenenti le intestazioni del messaggio e-mail
EmailDestinatario = Cstr(Messaggio.readline)
'Prima riga: indirizzo e-mail del destinatario
'First line: destination e-mail address
Oggetto = Cstr(Messaggio.readline)
'Seconda riga: Oggetto del messaggio
'Second line: subject
Body= ""
'Svuota la variabile e legge tutte le righe del corpo del messaggio.
'Empty the variable which will contain the body of the message.
Do While not Messaggio.AtEndOfStream
Body = Body & Messaggio.ReadLine & vbcrlf
Loop
Messaggio.Close 'Chiude il file contenente il messaggio

'Controllo validità dati. Control of e-mail address
'Se l'indirizzo del mittente non è una e-mail passa al prossimo messaggio.
if instr(1,EmailDestinatario, "@")>1 and instr(1,EmailDestinatario,".")>1
then
'Invia il messaggio. Sends the message
Set objMSG = objOL.CreateItem(0) 'Crea nuovo messaggio. Creates
new message.
With objMSG
.Subject = Oggetto
.To = EmailDestinatario
.Body = Body
.Send
End With
ContaMail = ContaMail +1 'Conta messaggi inviati. Counts messages
sent.
end if ' e-mail?
end if ' TXT?
Next 'File

Report = "Files: " & Messaggi.count & chr(13)
report = report & "Messaggi e-mail: " & ContaMail & chr(13)
report = report & "Fine Programma"
msgbox report ,,"Outlook Send Mail by Cenati Giovanni"




On Thu, 23 Oct 2003 14:07:34 -0700, "Bryan Kramer" <bryanekramer@msn.com> wrote:
>I am trying to send an email from a VBscript, outbound
>thru an SMTP server. My SMTP wants logon validation and I
>have not found how to do that yet! If I use MAPI and
>reference my 'Profile' which contains the login
>credentials then Outlook cries foul thinking my script is
>a virus trying to hijak my email account!
>How do I pass credentials from the script to send the
>email w/o getting frisked by outlook's security?
>

--
Giovanni Cenati (Aosta, Italy)
Write to user "nnever" and domain "@katamail.com"