Send/Receive while outlook closed?

A

adma

I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
receive even if outlook closed?
any help? thanks!


Sub ComposeMail(strto As String, strSubject As String, strbody As String,
strAttachment As String)
Dim objOL As Outlook.Application
Dim objX As Outlook.MailItem

Set objOL = New Outlook.Application
Set objX = objOL.CreateItem(olMailItem)
With objX
.To = strto
.Subject = strSubject
.Body = strbody
If strAttachment <> "" Then
.Attachments.Add strAttachment
End If
.BodyFormat = olFormatHTML
.Display
End With
Application.Wait (Now + TimeValue("0:00:02"))
Application.SendKeys "%s"
End Sub
 
J

JP

This might not be the answer you're looking for, but why not just
leave Outlook open?

--JP
 
O

Old Man River

Try putting a .send at the end of your With.

How are you early binding your objOL, I try that and am informed that excel
doesn't know about the Outlook class. and have to dimension as an Object and
use CreateObject.
 
A

adma via OfficeKB.com

the same, the message stays at the outbox.
Thanks for the reply
Try putting a .send at the end of your With.

How are you early binding your objOL, I try that and am informed that excel
doesn't know about the Outlook class. and have to dimension as an Object and
use CreateObject.
I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
[quoted text clipped - 23 lines]
 
O

Old Man River

Hi. In Outlook on the Tools Menu choose Options. Click the Mail Setup tab -
is "Send immeadiately when connected" selected? Might help.

adma via OfficeKB.com said:
the same, the message stays at the outbox.
Thanks for the reply
Try putting a .send at the end of your With.

How are you early binding your objOL, I try that and am informed that excel
doesn't know about the Outlook class. and have to dimension as an Object and
use CreateObject.
I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
[quoted text clipped - 23 lines]

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/outlook-prog-vba/200911/1

.
 
B

bobh

I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
receive even if outlook closed?
any help? thanks!

Sub ComposeMail(strto As String, strSubject As String, strbody As String,
strAttachment As String)
    Dim objOL As Outlook.Application
    Dim objX As Outlook.MailItem

    Set objOL = New Outlook.Application
    Set objX = objOL.CreateItem(olMailItem)
    With objX
        .To = strto
        .Subject = strSubject
        .Body = strbody
        If strAttachment <> "" Then
            .Attachments.Add strAttachment
        End If
        .BodyFormat = olFormatHTML
        .Display
    End With
    Application.Wait (Now + TimeValue("0:00:02"))
    Application.SendKeys "%s"
End Sub


I'm interested in doing this as well, if you find/get a resolve please
post it.
bobh.
 
B

bobh

Hi. In Outlook on the Tools Menu choose Options. Click the Mail Setup tab-
is "Send immeadiately when connected" selected? Might help.



adma via OfficeKB.com said:
the same, the message stays at the outbox.
Thanks for the reply
Old said:
Try putting a .send at the end of your With.
How are you early binding your objOL, I try that and am informed that excel
doesn't know about the Outlook class. and have to dimension as an Object and
use CreateObject.
I have this code to send email using Excel macro, it works fine abutthe
message stays in outbox until i open outlook then it sends it. how ican send
[quoted text clipped - 23 lines]
.
.- Hide quoted text -

- Show quoted text -

but you still have to open outlook in order for it to connect and send
bobh
 
B

bobh

This might not be the answer you're looking for, but why not just
leave Outlook open?

--JP





- Show quoted text -

if his situation is like mine;
I developed an Access application that has multiple users and I can
not make the assumption that all the users will have Outlook open so
when entering data on the Access data entry screen should they click
the 'Notify Manager' button I want the Noticification email to be send
in the background without user interaction and without having to
ensure that Outlook is open which so far I have NOT been able to do
using Outlook as the companies EMail client software.
So the issue is why does Outlook but the email message in it's outbox
instead of just sending it.
bobh.
 
A

adma via OfficeKB.com

thats exactly what is my problem, i have searched the net for solution but
nothing yes.


I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
[quoted text clipped - 21 lines]
    Application.SendKeys "%s"
End Sub

I'm interested in doing this as well, if you find/get a resolve please
post it.
bobh.
 
A

adma via OfficeKB.com

it did not help , still puts it in the outbox



Try putting a .send at the end of your With.

How are you early binding your objOL, I try that and am informed that excel
doesn't know about the Outlook class. and have to dimension as an Object and
use CreateObject.
I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
[quoted text clipped - 23 lines]
 
J

JP

I understand your (and everyone else's) concern regarding this issue,
but there is a solution: leave Outlook open. Who doesn't leave it open
all day to get meeting reminders, receive important emails from the
boss, etc anyway?

If you want to send an email without user interaction, and you must
use Outlook, try using Redemption (http://www.dimastr.com/
redemption/). Or see http://www.rondebruin.nl/sendmail.htm for other
tips.

As a workaround, use GetObject to see if Outlook is open, and if it
isn't, warn your end users (via MsgBox) that without Outlook open,
their messages will be delayed.

--JP
 
A

adma via OfficeKB.com

Thanks!
i will try and let you know which one works for me.


I understand your (and everyone else's) concern regarding this issue,
but there is a solution: leave Outlook open. Who doesn't leave it open
all day to get meeting reminders, receive important emails from the
boss, etc anyway?

If you want to send an email without user interaction, and you must
use Outlook, try using Redemption (http://www.dimastr.com/
redemption/). Or see http://www.rondebruin.nl/sendmail.htm for other
tips.

As a workaround, use GetObject to see if Outlook is open, and if it
isn't, warn your end users (via MsgBox) that without Outlook open,
their messages will be delayed.

--JP
[quoted text clipped - 42 lines]
- Show quoted text -
 
A

adma via OfficeKB.com

i used redemption, copied installed it added to reference library


i copied their example into a sub for testing

Sub redemail()

Dim SafeItem, oItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of
Redemption.SafeMailItem
Set oItem = Application.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "(e-mail address removed)"
SafeItem.Recipients.ResolveAll
SafeItem.Subject = "Testing Redemption"
SafeItem.Send


End Sub



here is the error
run-time error '438':

Object doesn't support this property or method at this line
'Set oItem = Application.CreateItem(0) 'Create a new message

what shall i do?

any help?
I understand your (and everyone else's) concern regarding this issue,
but there is a solution: leave Outlook open. Who doesn't leave it open
all day to get meeting reminders, receive important emails from the
boss, etc anyway?

If you want to send an email without user interaction, and you must
use Outlook, try using Redemption (http://www.dimastr.com/
redemption/). Or see http://www.rondebruin.nl/sendmail.htm for other
tips.

As a workaround, use GetObject to see if Outlook is open, and if it
isn't, warn your end users (via MsgBox) that without Outlook open,
their messages will be delayed.

--JP
[quoted text clipped - 42 lines]
- Show quoted text -
 
J

JP

You're in Excel, trying to use code written for Outlook. You need to
create an instance of Outlook.Application, then use that reference.

i.e.

Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
Set oItem = olApp.CreateItem(0) 'Create a new message


--JP
 
A

adma via OfficeKB.com

i have this code which worked fine but still can not send it out unless i
open outlook

i have outlook 2003

i am sooo sadddddd


Sub redmail()
Dim SafeItem, oItem
Dim objOL As Outlook.Application
Dim objX As Outlook.MailItem

Set objOL = New Outlook.Application
Set objX = objOL.CreateItem(0)
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of
Set oItem = objOL.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "(e-mail address removed)"
SafeItem.Subject = "Deamdn File"
SafeItem.Recipients.ResolveAll

SafeItem.Send

End Sub



thats exactly what is my problem, i have searched the net for solution but
nothing yes.
[quoted text clipped - 5 lines]
post it.
bobh.
 
O

Old Man River

Hi adma.

I was just browsing Outlook Object Model and found this

Sub SendAndReceive(showProgressDialog As Boolean)
Member of Outlook.NameSpace

Remembering your request you could try objOL.Namespace.SendAndRecieve(False)

No Guarantees as I haven't used it. (You might test Namespace to see if its
null though.)

adma via OfficeKB.com said:
i have this code which worked fine but still can not send it out unless i
open outlook

i have outlook 2003

i am sooo sadddddd


Sub redmail()
Dim SafeItem, oItem
Dim objOL As Outlook.Application
Dim objX As Outlook.MailItem

Set objOL = New Outlook.Application
Set objX = objOL.CreateItem(0)
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of
Set oItem = objOL.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "(e-mail address removed)"
SafeItem.Subject = "Deamdn File"
SafeItem.Recipients.ResolveAll

SafeItem.Send

End Sub



thats exactly what is my problem, i have searched the net for solution but
nothing yes.
I have this code to send email using Excel macro, it works fine abut the
message stays in outbox until i open outlook then it sends it. how i can send
[quoted text clipped - 5 lines]
post it.
bobh.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/outlook-prog-vba/200911/1

.
 
A

adma via OfficeKB.com

It did not help.

thanks!
Hi adma.

I was just browsing Outlook Object Model and found this

Sub SendAndReceive(showProgressDialog As Boolean)
Member of Outlook.NameSpace

Remembering your request you could try objOL.Namespace.SendAndRecieve(False)

No Guarantees as I haven't used it. (You might test Namespace to see if its
null though.)
i have this code which worked fine but still can not send it out unless i
open outlook
[quoted text clipped - 29 lines]
 
S

Sue Mosher [MVP]

Another glance at the Outlook object browser would tell you why it won't
work: There is no Application.Namespace property. There is, however, an
Application.Session property that returns a Namespace object, thus:
objOL.Session.SendAndReceive(False), assuming you have a valid objOL
(Outlook.Application) object.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


adma via OfficeKB.com said:
It did not help.

thanks!
Hi adma.

I was just browsing Outlook Object Model and found this

Sub SendAndReceive(showProgressDialog As Boolean)
Member of Outlook.NameSpace

Remembering your request you could try
objOL.Namespace.SendAndRecieve(False)

No Guarantees as I haven't used it. (You might test Namespace to see if
its
null though.)
i have this code which worked fine but still can not send it out unless
i
open outlook
[quoted text clipped - 29 lines]
 
A

adma via OfficeKB.com

not this one too, still cant have it send the email
Sue said:
Another glance at the Outlook object browser would tell you why it won't
work: There is no Application.Namespace property. There is, however, an
Application.Session property that returns a Namespace object, thus:
objOL.Session.SendAndReceive(False), assuming you have a valid objOL
(Outlook.Application) object.
It did not help.
[quoted text clipped - 18 lines]
open outlook
[quoted text clipped - 29 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top