Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Log Sent Email in the Sent Items folder on server when sending VBScript emails

Posted on 2013-12-06
12
Medium Priority
?
1,120 Views
Last Modified: 2014-06-10
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.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
0
Comment
Question by:100questions
  • 4
  • 3
12 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 39701194
This is sending an smtp message.  It is nothing to do with any mailbox so it won't go into any sent box.

Options.

1. Send scripted using Outlook from a client or whatever you are using for your mail system using a mailbox configured on there.
2. Add a Blind copy to the message to a logs@yourdomain.com mailbox or similar.

Then in that mailbox either just leave them be or add rules to the mailbox to shift mails based on the address/subject etc. into suitable folders.

With objMessage
  .Subject = Subject
  .From = From
  .To = MailTo
  .TextBody = Body
  .bcc = "logs@mydomain.com"
 End With

Steve
0
 

Author Comment

by:100questions
ID: 39701644
Thanks, what do you mean by send scripted in option 1?  Outlook would be a good option.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39701802
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
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:100questions
ID: 39718695
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
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39718704
Seriously?

Your code:

 With objMessage
  .Subject = Subject
  .From = From
  .To = MailTo
  .TextBody = Body
 End With

Open in new window


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 

Open in new window


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 

Open in new window

0
 

Author Comment

by:100questions
ID: 39746717
I suppose this might work, have not tested it yet.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 40117827
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40117828
I'd suggest accept dragon-it http:#39701194

You've been busy with the cleanups Qlemo, can't keep up with the emails!!

Steve
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
This program is used to assist in finding and resolving common problems with wireless connections.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question