?
Solved

Scheduled Task to run VB Script - send email

Posted on 2005-03-29
5
Medium Priority
?
278 Views
Last Modified: 2012-08-13
Hi,

I have the following code created as .VBS file and I set the scheduled task to run this weekly.
However, as I'm running this off my laptop where my outlook prompts me to connect or not.
Thus when this starts running - it'll gives me the outlook prompt and then it has the another prompt to ask "A program is trying to send an email on your behalf. Do you want to aloow this?"

Is there any way I make the code to skip both of the prompts?

"Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)

myItem.To = "test@testing.com"
myItem.Subject = "Message for you sir!"
myItem.Body = "Body here."

myItem.Send "

Thanks, any help would be appreciated.
0
Comment
Question by:cyberp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 1000 total points
ID: 13650833
Hi cyberp,

a)

Whats the connection message? Is your Outlook instance visisble?

For b)

Using the Redemption.dll is your best bet, see http://www.outlookcode.com/d/sec.htm

Others prefer this program which monitors the security message and clicks it for you, http://www.contextmagic.com/express-clickyes/

Cheers

Dave
0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 1000 total points
ID: 13651185
Hi brettdj,

If Outlook isn't already running, then you have to log in to an Outlook profile to avoid the first of the two prompts.  brettdj has already covered the second prompt and how to get around it.  Here's your code modified to avoid the first prompt:

Set myOlApp = CreateObject("Outlook.Application")
Set myOlNS = myOlApp.GetNameSpace("MAPI")
'Change ProfileName on the next line to the name of your Outlook profile
myOlNS.Logon ProfileName
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.To = "test@testing.com"
myItem.Subject = "Message for you sir!"
myItem.Body = "Body here."
myItem.Send
myOlNS.Logoff
'You should always dispose of objects before ending the script.  This helps avoid memory leaks.
Set myItem = Nothing
Set myOlNS = Nothing
Set myOlApp = Nothing

Cheers!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 13651188
Oops, my previous post should have been addressed to cyberp not brettdj.  Sorry.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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