why this program doesn't work if Outlook is not manually launched?

Status
Not open for further replies.
Q

qwerty123456

Hello,

can someone tell me why this stupid program works if I run manually Outlook

2007, but doesn't work when Outlook2007 is not in execution?

The error is when accessing the Recipients collection. But I can't

understand why it works if Outlook 2007 is running previously I ran the

script.

Many thanks to all who will answer.

Luca D

' Copy the following text and put it into a new text file with the .vbs

extention

Dim oApp, oMail

Set oApp = CreateObject("Outlook.Application")

Set oMail = oApp.createitem(0)

oMail.subject = "Email Subject"

oMail.body = "hello all"

oMail.recipients.add("youremail@yourprovider.com")

oMail.send()

' uncomment the following to close Outlook

'oApp.quit()
 
S

Sue Mosher [MVP]

It's hard to answer your question without knowing what the error is. I'd

suggest you take a look at the code sample at

http://www.outlookcode.com/codedetail.aspx?id=83, paying particular

attention to the Logon statement.

Sue Mosher

"qwerty123456" <qwerty123456> wrote in message

news:115C4E02-DF36-4B0D-B388-CF630711DA05@microsoft.com...
> Hello,
> can someone tell me why this stupid program works if I run manually
> Outlook
> 2007, but doesn't work when Outlook2007 is not in execution?
> The error is when accessing the Recipients collection. But I can't
> understand why it works if Outlook 2007 is running previously I ran the
> script.

> Many thanks to all who will answer.

> Luca D

> ' Copy the following text and put it into a new text file with the .vbs
> extention
> Dim oApp, oMail

> Set oApp = CreateObject("Outlook.Application")
> Set oMail = oApp.createitem(0)
> oMail.subject = "Email Subject"
> oMail.body = "hello all"
> oMail.recipients.add("youremail@yourprovider.com")
> oMail.send()
> ' uncomment the following to close Outlook
> 'oApp.quit()

>
 
Q

qwerty123456

Re: why this program doesn't work if Outlook is not manually launc

The error is "Operation Aborted".

(I thought the program was so simple that worth a run)

Thanks

Luca D

"Sue Mosher [MVP]" wrote:


> It's hard to answer your question without knowing what the error is. I'd
> suggest you take a look at the code sample at
> http://www.outlookcode.com/codedetail.aspx?id=83, paying particular
> attention to the Logon statement.

> > Sue Mosher
> > >

> "qwerty123456" <qwerty123456> wrote in message
> news:115C4E02-DF36-4B0D-B388-CF630711DA05@microsoft.com...
> > Hello,
> > can someone tell me why this stupid program works if I run manually
> > Outlook
> > 2007, but doesn't work when Outlook2007 is not in execution?
> > The error is when accessing the Recipients collection. But I can't
> > understand why it works if Outlook 2007 is running previously I ran the
> > script.
> > Many thanks to all who will answer.
> > Luca D
> > ' Copy the following text and put it into a new text file with the .vbs
> > extention
> > Dim oApp, oMail
> > Set oApp = CreateObject("Outlook.Application")
> > Set oMail = oApp.createitem(0)
> > oMail.subject = "Email Subject"
> > oMail.body = "hello all"
> > oMail.recipients.add("youremail@yourprovider.com")
> > oMail.send()
> > ' uncomment the following to close Outlook
> > 'oApp.quit()
> >


>
 
D

Dmitry Streblechenko

Try the following:

Set oApp = CreateObject("Outlook.Application")

set oNS = oApp.GetNamespace("MAPI");

oNS.Logon;

Set oMail = oApp.createitem(0)

oMail.subject = "Email Subject"

oMail.body = "hello all"

oMail.recipients.add("youremail@yourprovider.com")

oMail.send()

Dmitry Streblechenko (MVP)

-

"qwerty123456" <qwerty123456> wrote in message

news:115C4E02-DF36-4B0D-B388-CF630711DA05@microsoft.com...
> Hello,
> can someone tell me why this stupid program works if I run manually
> Outlook
> 2007, but doesn't work when Outlook2007 is not in execution?
> The error is when accessing the Recipients collection. But I can't
> understand why it works if Outlook 2007 is running previously I ran the
> script.

> Many thanks to all who will answer.

> Luca D

> ' Copy the following text and put it into a new text file with the .vbs
> extention
> Dim oApp, oMail

> Set oApp = CreateObject("Outlook.Application")
> Set oMail = oApp.createitem(0)
> oMail.subject = "Email Subject"
> oMail.body = "hello all"
> oMail.recipients.add("youremail@yourprovider.com")
> oMail.send()
> ' uncomment the following to close Outlook
> 'oApp.quit()

>
 
Q

qwerty123456

Re: why this program doesn't work if Outlook is not manually launc

Excelent, now it works.

thanks

Luca D

"Dmitry Streblechenko" wrote:


> Try the following:

> Set oApp = CreateObject("Outlook.Application")
> set oNS = oApp.GetNamespace("MAPI");
> oNS.Logon;
> Set oMail = oApp.createitem(0)
> oMail.subject = "Email Subject"
> oMail.body = "hello all"
> oMail.recipients.add("youremail@yourprovider.com")
> oMail.send()

> > Dmitry Streblechenko (MVP)
>

>

>

> -
> "qwerty123456" <qwerty123456> wrote in message
> news:115C4E02-DF36-4B0D-B388-CF630711DA05@microsoft.com...
> > Hello,
> > can someone tell me why this stupid program works if I run manually
> > Outlook
> > 2007, but doesn't work when Outlook2007 is not in execution?
> > The error is when accessing the Recipients collection. But I can't
> > understand why it works if Outlook 2007 is running previously I ran the
> > script.
> > Many thanks to all who will answer.
> > Luca D
> > ' Copy the following text and put it into a new text file with the .vbs
> > extention
> > Dim oApp, oMail
> > Set oApp = CreateObject("Outlook.Application")
> > Set oMail = oApp.createitem(0)
> > oMail.subject = "Email Subject"
> > oMail.body = "hello all"
> > oMail.recipients.add("youremail@yourprovider.com")
> > oMail.send()
> > ' uncomment the following to close Outlook
> > 'oApp.quit()
> >


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Program Checkbox that will activate a text box in a Outlook fallible form. Outlook VBA and Custom Forms 1
T Outlook "A program is trying to access Outlook" Using Outlook 3
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
R SearchPublicFolders program Outlook VBA and Custom Forms 1
Diane Poremsky To Change the Default E-mail Program in Windows New Slipstick.com Articles 0
I There is no email program associated to perform requested action Using Outlook 0
Diane Poremsky Trial/Beta program for BCM replacement BCM (Business Contact Manager) 8
J it goes like outlook has stopped working, a problem caused the program to stop working correctly, wi Using Outlook 2
J My Outlook program has stopped receiving. I can still send Using Outlook 1
C New version of MFCMAPI program Using Outlook 0
K A program is trying to send an e-mail message on your behalf... Using Outlook 1
A outlook 2007 - there is no email program associated ... Using Outlook 3
F Default Program for Opening .pst Files ? Using Outlook 6
A Outlook-Program Not Closing Properly Using Outlook 10
B How to remove an old program from the Tools dropdown? Using Outlook 7
D How to set permissions to allow external program to send an email? Using Outlook 0
T getting an error This file does not have a program associated with it for performing this action. C Using Outlook 7
N The add-in "C:\program files\google\google desktop search\googledesktopO..." could not be installed Using Outlook 32
R Access Program Only Looping Part Way Through Outlook Inbox Outlook VBA and Custom Forms 2
M Allow or Deny when a Program tries to send an email Outlook VBA and Custom Forms 1
R how to (re)set the default data file for Outlook in a VB program Outlook VBA and Custom Forms 2
J Program won't end in Win7 Outlook VBA and Custom Forms 1
D Outlook 2003 - A program is trying to access e-mail addresses Outlook VBA and Custom Forms 5
D Running a Program from Custom Action Rule Outlook VBA and Custom Forms 1
S Email Organizer Program Outlook VBA and Custom Forms 2
G GAL program acces in outlook 2007 Outlook VBA and Custom Forms 2
H Program "Click on Ribbon Button" Using VBA Outlook VBA and Custom Forms 1
H Program email save as text file Outlook VBA and Custom Forms 5
M Run external program from Outlook VBA macro Outlook VBA and Custom Forms 5
N How to attach a file with MS Outlook, from a program? Outlook VBA and Custom Forms 3
V how to switchoff program access message in outlook 2003 Outlook VBA and Custom Forms 1
V "A program has attachment filename open" Message returns Outlook VBA and Custom Forms 4
J Program Compatibility Issue - Outlook 2003 BCM BCM (Business Contact Manager) 4
R Why doesn't outlook use "Normal" style for new messages? Using Outlook 4
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
R Follow up button doesn't working neither the reminders in BCM BCM (Business Contact Manager) 0
Terry Sullivan Sender's Name Doesn't Appear in the From Field on Outlook 365/IMAP Using Outlook 2
B VBScript doesn't run on Recipient Email Outlook VBA and Custom Forms 2
P Outlook Mobile App Doesn't Refresh Inbox Using Outlook 0
DoctorJellybean Outlook 365 doesn't always mark emails as read Using Outlook 3
GregS Simple calendar sharing doesn't work Using Outlook 6
G Calendar View in Outlook Office 365 - Doesn't show enough hours, and the 30/60 min choice isn't the solution Using Outlook 4
P Desktop doesn't index Outlook IMAP files, laptop Outlook does index those same IMAP files Using Outlook 2
B Outlook rule run a Script doesn't work Outlook VBA and Custom Forms 1
E Accessing shared outlook folder doesn't work since switch to new outlook/excel Outlook VBA and Custom Forms 11
H VB script in outlook form doesn't work anymore Outlook VBA and Custom Forms 2
J Junk mail doesn't work Using Outlook 3
J Custom form code doesn't run Outlook VBA and Custom Forms 2
Laurent Duchastel New email setup dialog doesn't allow alias Using Outlook 2
M Item edits doesn't always sync Using Outlook 11

Similar threads

Top