E=mc2
asked on
Log Sent Email in the Sent Items folder on server when sending VBScript emails
Currently, this script does not log the Sent emails to my knowledge.
I need for this script to be modified so that it records or shows the sent email sin the Sent Items folders on the Exchange server.
MailTo = "email@email.com"
From = "email@email.com"
Subject = "Test Email"
Body = "This is an VBScript - Test."
Username = "user"
Password = "password"
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.F ields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
objMessage.Send
End Sub
I need for this script to be modified so that it records or shows the sent email sin the Sent Items folders on the Exchange server.
MailTo = "email@email.com"
From = "email@email.com"
Subject = "Test Email"
Body = "This is an VBScript - Test."
Username = "user"
Password = "password"
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.F
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
objMessage.Send
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rather than sending an smtp message, connecting to and installation of outlook on the machine in question, connect to a mailbox, create a message and hit send effecively.
Much easier to do what I suggested with a bcc and rule in whatever mailbox watned.
Steve
Much easier to do what I suggested with a bcc and rule in whatever mailbox watned.
Steve
ASKER
Thanks. where would I place in the original script, your code:
With objMessage
.Subject = Subject
.From = From
.To = MailTo
.TextBody = Body
.bcc = "logs@mydomain.com"
End With
With objMessage
.Subject = Subject
.From = From
.To = MailTo
.TextBody = Body
.bcc = "logs@mydomain.com"
End With
Seriously?
Your code:
Suggested change:
With objMessage
.Subject = Subject
.From = From
.To = MailTo
.TextBody = Body
.bcc = "logs@mydomain.com"
End With
You can make things into your SUB as an option if you wish:
Or remove all the temporary variables:
Your code:
With objMessage
.Subject = Subject
.From = From
.To = MailTo
.TextBody = Body
End With
Suggested change:
With objMessage
.Subject = Subject
.From = From
.To = MailTo
.TextBody = Body
.bcc = "logs@mydomain.com"
End With
You can make things into your SUB as an option if you wish:
MailTo = "email@email.com"
BCC = "log@email.com"
From = "email@email.com"
Subject = "Test Email"
Body = "This is an VBScript - Test."
Username = "user"
Password = "password"
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
.TextBody = Body
.Bcc = BCC
End With
With objMessage.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
objMessage.Send
End Sub
Or remove all the temporary variables:
Body = "This is an VBScript - Test."
Email "myto@email.com","mybcc@email.com","myfrom@email.com","Subject line",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
.TextBody = Body
.Bcc = BCC
End With
With objMessage.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = user
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Update
End With
objMessage.Send
End Sub
ASKER
I suppose this might work, have not tested it yet.
I've requested that this question be deleted for the following reason:
Not enough information to confirm an answer.
Not enough information to confirm an answer.
I'd suggest accept dragon-it http:#39701194
You've been busy with the cleanups Qlemo, can't keep up with the emails!!
Steve
You've been busy with the cleanups Qlemo, can't keep up with the emails!!
Steve
ASKER