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

  • Thread starter Thread starter qwerty123456
  • Start date Start date
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()
 
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()

>
 
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()
> >


>
 
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()

>
 
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
P Recommendation for PST repair program Using Outlook 1
P Outlook 365 Bad experience with KernelAPPS PST Repair program Using Outlook 0
P anyone use 4n6' Eudora Conversion program or other programs? Using Outlook 1
P How to clear out all contacts in iCloud, so I can use iCloud-based sync program Using Outlook 1
S Email Generated from another program and then edited sends original email. Using Outlook 2
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 Using Outlook 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
G Outlook 365 My iCloud Outlook doesn’t work after reinstalling Microsoft365 on Windows 10 PC – now I get error message on contacts and calendar Using Outlook 1
E Save Selected Email Message as .msg File - digitally sign email doesn't works Outlook VBA and Custom Forms 1
M Shift Delete doesn't delete email from server Using Outlook 3
C Outlook doesn't feel reliable, anymore Using Outlook 5
C View doesn't refresh (fields or formatting) Using Outlook 1
J search doesn't find anything Using Outlook 1
gproston Why doesn't Outlook remember indexing? Using Outlook 1
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

Similar threads

Back
Top