Redemption Send EMail

Status
Not open for further replies.
P

Peter Hibbs

With Outlook 2003 and Access 2003 I am using the following code to

send emails from an Access database using Outlook Redemption.

Dim SafeItem As Object, oItem As Object

Dim objApp As Object, NS As Object

'Create instance of Outlook Application

Set objApp = CreateObject("Outlook.Application")

Set NS = objApp.GetNamespace("MAPI")

NS.Logon

'Create an instance of Redemption.SafeMailItem

Set SafeItem = CreateObject("Redemption.SafeMailItem")

Set oItem = objApp.CreateItem(0)

SafeItem.Item = oItem

SafeItem.To = "email address here"

SafeItem.Subject = "email subject text"

SafeItem.BodyFormat = 2

SafeItem.HTMLBody = "email body text"

'Send email and close

SafeItem.Send

Set SafeItem = Nothing

Set oItem = Nothing

Set NS = Nothing

Set objApp = Nothing

I notice that the email ONLY gets sent if Outlook is actually running.

Is this correct and, if so, is there any way to send an email while

Outlook is NOT loaded?

Peter Hibbs.
 
If Outlook is set to send emails immediately, which usually means within the

next minute, you just need to wait until the mail is sent before you close

Outlook.

Best regards

Michael Bauer

Am Sun, 30 Aug 2009 14:52:19 +0100 schrieb Peter Hibbs:


> With Outlook 2003 and Access 2003 I am using the following code to
> send emails from an Access database using Outlook Redemption.

> Dim SafeItem As Object, oItem As Object
> Dim objApp As Object, NS As Object

> 'Create instance of Outlook Application
> Set objApp = CreateObject("Outlook.Application")
> Set NS = objApp.GetNamespace("MAPI")
> NS.Logon

> 'Create an instance of Redemption.SafeMailItem
> Set SafeItem = CreateObject("Redemption.SafeMailItem")
> Set oItem = objApp.CreateItem(0)
> SafeItem.Item = oItem
> SafeItem.To = "email address here"
> SafeItem.Subject = "email subject text"

> SafeItem.BodyFormat = 2
> SafeItem.HTMLBody = "email body text"

> 'Send email and close
> SafeItem.Send
> Set SafeItem = Nothing
> Set oItem = Nothing
> Set NS = Nothing
> Set objApp = Nothing

> I notice that the email ONLY gets sent if Outlook is actually running.
> Is this correct and, if so, is there any way to send an email while
> Outlook is NOT loaded?

> Peter Hibbs.
 
Michael,

I was sort of under the impression that the Redemption code worked

independently of Outlook (although Outlook needs to be installed).

Having said that, I don't know why as there is no indication of that

on Dmitry's Web site, perhaps I read it somewhere.

Anyway, I was hoping that it would be possible to send an email from

within Access without having Outlook running but you appear to be

saying that that is not possible. I do have the 'Send immediately when

connected' flag set and the code works fine with Outlook running.

Oh well!!

Peter Hibbs.

On Mon, 31 Aug 2009 09:42:47 +0200, "Michael Bauer "

<mb@mvps.org> wrote:



> If Outlook is set to send emails immediately, which usually means within the
> next minute, you just need to wait until the mail is sent before you close
> Outlook.
 
You can send without Outlook running, but you need to be using Exchange for

that to work. If you log into an Exchange mailbox you can do so without

running Outlook as long as you have the server-side MAPI installed. That

means no Office installed at all. Then you can send an item and Exchange

will take care of getting it out. I do that for some Windows services I've

written.

Other than that you do need an Outlook session running to actually have an

email go out.

"Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message

news:upin95t2gs39n5rsdfl3s23visfo0vgoug@4ax.com...
> Michael,

> I was sort of under the impression that the Redemption code worked
> independently of Outlook (although Outlook needs to be installed).
> Having said that, I don't know why as there is no indication of that
> on Dmitry's Web site, perhaps I read it somewhere.

> Anyway, I was hoping that it would be possible to send an email from
> within Access without having Outlook running but you appear to be
> saying that that is not possible. I do have the 'Send immediately when
> connected' flag set and the code works fine with Outlook running.

> Oh well!!

> Peter Hibbs.
 
OK Ken, thanks for that.

I don't know anything about 'Exchange' but I will look into it. I

suspect it will be easier just to have Outlook running (it probably

will be anyway).

Peter Hibbs.

On Mon, 31 Aug 2009 09:44:57 -0400, "
<kenslovak@mvps.org> wrote:


> You can send without Outlook running, but you need to be using Exchange for
> that to work. If you log into an Exchange mailbox you can do so without
> running Outlook as long as you have the server-side MAPI installed. That
> means no Office installed at all. Then you can send an item and Exchange
> will take care of getting it out. I do that for some Windows services I've
> written.

> Other than that you do need an Outlook session running to actually have an
> email go out.
 
Exchange is a mail server, if you're not familiar with it you're not using

it most likely. It's for corporations, not for home or private users.

"Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message

news:vssn951eg349rnlsldjmnh9s8m8mqlr8qe@4ax.com...
> OK Ken, thanks for that.

> I don't know anything about 'Exchange' but I will look into it. I
> suspect it will be easier just to have Outlook running (it probably
> will be anyway).

> Peter Hibbs.
 
Actually your code does start Outlook. But if it was not launched by a user

prior to that, it will close after your code is finished.

See http://www.dimastr.com/redemption/faq.htm#1

Dmitry Streblechenko (MVP)

-

"Peter Hibbs" <peter.hibbs@btinternet.com.NO_SPAM> wrote in message

news:upin95t2gs39n5rsdfl3s23visfo0vgoug@4ax.com...
> Michael,

> I was sort of under the impression that the Redemption code worked
> independently of Outlook (although Outlook needs to be installed).
> Having said that, I don't know why as there is no indication of that
> on Dmitry's Web site, perhaps I read it somewhere.

> Anyway, I was hoping that it would be possible to send an email from
> within Access without having Outlook running but you appear to be
> saying that that is not possible. I do have the 'Send immediately when
> connected' flag set and the code works fine with Outlook running.

> Oh well!!

> Peter Hibbs.

> On Mon, 31 Aug 2009 09:42:47 +0200, "Michael Bauer "
> <mb@mvps.org> wrote:
>
>

>
>>If Outlook is set to send emails immediately, which usually means within
> >the
> >next minute, you just need to wait until the mail is sent before you close
> >Outlook.
 
Dmitry,

Not sure I understand. Are you saying that if I add this code (from

your Web site) to my code that it will send the email without Outlook

loaded? If so, then I cannot get it to work, or perhaps I have

mis-read your FAQ #1.

"Note that the code above assumes that there is an active Explorer;

this will not be the case if you start Outlook programmatically (and

it was not previously started by a user) and do not display any

folders. In this case you can start a sync using the the

Namespace.SyncObjects collection."

set NS = Application.GetNamespace("MAPI")

NS.Logon

Set Sync = NS.SyncObjects.Item(1)

Sync.Start

Peter Hibbs.

On Mon, 31 Aug 2009 11:16:48 -0700, "Dmitry Streblechenko"

<dmitry@dimastr.com> wrote:


> Actually your code does start Outlook. But if it was not launched by a user
> prior to that, it will close after your code is finished.
> See http://www.dimastr.com/redemption/faq.htm#1
 
That's what I wanted to tell you as well. Your code starts Outlook, but it

closes it as soon as the execution has been finished because the variables

go out of scope.

In principle a solution might look like this (asuming that Outlook isn't

running yet):

Private m_OL as Outlook.Application

Private m_Exp as Outlook.Explorer

Private m_Ns as Outlook.Namespace

Sub Start()

Dim F as Outlook.Mapifolder

Set m_OL = CreateObject("outlook.application")

Set m_Ns=m_OL.GetNamespace("mapi")

Set F=m_Ns.GetDefaultFolder(olFolderInbox)

Set m_Exp=m_OL.Explorers.Add(F, 0)

' now create/send the email

End Sub

' Use a timer to call this method, say, every minute

Sub CheckIfMailIsSent()

Dim F as Outlook.Mapifolder

Set F=m_Ns.GetDefaultFolder(olFolderOutbox)

If F.Items.Count=0 Then

' assuming the email is sent now

' disable your timer (!), then close Outlook

m_Exp.Close

Set m_Exp=Nothing

Set m_Ns=Nothing

m_OL.Quit

Set m_OL=Nothing

Endif

End sub

Best regards

Michael Bauer

Am Mon, 31 Aug 2009 22:01:04 +0100 schrieb Peter Hibbs:


> Dmitry,

> Not sure I understand. Are you saying that if I add this code (from
> your Web site) to my code that it will send the email without Outlook
> loaded? If so, then I cannot get it to work, or perhaps I have
> mis-read your FAQ #1.

> "Note that the code above assumes that there is an active Explorer;
> this will not be the case if you start Outlook programmatically (and
> it was not previously started by a user) and do not display any
> folders. In this case you can start a sync using the the
> Namespace.SyncObjects collection."

> set NS = Application.GetNamespace("MAPI")
> NS.Logon
> Set Sync = NS.SyncObjects.Item(1)
> Sync.Start

> Peter Hibbs.

> On Mon, 31 Aug 2009 11:16:48 -0700, "Dmitry Streblechenko"
> <dmitry@dimastr.com> wrote:
>
> >Actually your code does start Outlook. But if it was not launched by a


user
> >prior to that, it will close after your code is finished.
> >See http://www.dimastr.com/redemption/faq.htm#1
 
Michael,

I looked at your suggestion but I could not get it to work (probably

me) and I am not sure now if using Redemption will meet my

requirements on this project anyway.

I have done a bit more research and found some code called OstroSoft

SMTP Component by Igor Ostrovsky (OstroSoft). I have successfully got

the demo database program working and am now trying to integrate the

code into my own database.

Have you any comments about this code that I should know about?

Thanks for your help.

Peter Hibbs.

On Tue, 1 Sep 2009 09:58:33 +0200, "Michael Bauer "

<mb@mvps.org> wrote:



> That's what I wanted to tell you as well. Your code starts Outlook, but it
> closes it as soon as the execution has been finished because the variables
> go out of scope.

> In principle a solution might look like this (asuming that Outlook isn't
> running yet):

> Private m_OL as Outlook.Application
> Private m_Exp as Outlook.Explorer
> Private m_Ns as Outlook.Namespace

> Sub Start()
> Dim F as Outlook.Mapifolder
> Set m_OL = CreateObject("outlook.application")
> Set m_Ns=m_OL.GetNamespace("mapi")
> Set F=m_Ns.GetDefaultFolder(olFolderInbox)
> Set m_Exp=m_OL.Explorers.Add(F, 0)
> ' now create/send the email
> End Sub

> ' Use a timer to call this method, say, every minute
> Sub CheckIfMailIsSent()
> Dim F as Outlook.Mapifolder
> Set F=m_Ns.GetDefaultFolder(olFolderOutbox)
> If F.Items.Count=0 Then
> ' assuming the email is sent now
> ' disable your timer (!), then close Outlook
> m_Exp.Close
> Set m_Exp=Nothing
> Set m_Ns=Nothing
> m_OL.Quit
> Set m_OL=Nothing
> Endif
> End sub
 
I don't know that component.

Best regards

Michael Bauer

Am Wed, 02 Sep 2009 17:09:00 +0100 schrieb Peter Hibbs:


> Michael,

> I looked at your suggestion but I could not get it to work (probably
> me) and I am not sure now if using Redemption will meet my
> requirements on this project anyway.

> I have done a bit more research and found some code called OstroSoft
> SMTP Component by Igor Ostrovsky (OstroSoft). I have successfully got
> the demo database program working and am now trying to integrate the
> code into my own database.

> Have you any comments about this code that I should know about?

> Thanks for your help.

> Peter Hibbs.

> On Tue, 1 Sep 2009 09:58:33 +0200, "Michael Bauer "
> <mb@mvps.org> wrote:
>
>

>
>>That's what I wanted to tell you as well. Your code starts Outlook, but it
> >closes it as soon as the execution has been finished because the variables
> >go out of scope.
>

>>In principle a solution might look like this (asuming that Outlook isn't
> >running yet):
>

>>Private m_OL as Outlook.Application
> >Private m_Exp as Outlook.Explorer
> >Private m_Ns as Outlook.Namespace
>

>>Sub Start()
> > Dim F as Outlook.Mapifolder
> > Set m_OL = CreateObject("outlook.application")
> > Set m_Ns=m_OL.GetNamespace("mapi")
> > Set F=m_Ns.GetDefaultFolder(olFolderInbox)
> > Set m_Exp=m_OL.Explorers.Add(F, 0)
> > ' now create/send the email
> >End Sub
>

>>' Use a timer to call this method, say, every minute
> >Sub CheckIfMailIsSent()
> > Dim F as Outlook.Mapifolder
> > Set F=m_Ns.GetDefaultFolder(olFolderOutbox)
> > If F.Items.Count=0 Then
> > ' assuming the email is sent now
> > ' disable your timer (!), then close Outlook
> > m_Exp.Close
> > Set m_Exp=Nothing
> > Set m_Ns=Nothing
> > m_OL.Quit
> > Set m_OL=Nothing
> > Endif
> >End sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Redemption Send EMail fails Outlook VBA and Custom Forms 4
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
N Redemption VBA basics...something's missing Using Outlook 0
D Redemption? Need rapid pull of Outlook Contacts, email + notes for VBA Using Outlook 1
J 64-bit version of Redemption? Outlook VBA and Custom Forms 2
E Redemption access AppointmentItem Label from outlook Outlook VBA and Custom Forms 6
E Redemption MAPI access(c#) Outlook VBA and Custom Forms 4
W Redemption::RDOMail.PrintOut() / DoAction(maPrint) not working Outlook VBA and Custom Forms 1
B Use Redemption to get sender's email address Outlook VBA and Custom Forms 3
M EMail1Address and EMail1AddressType strangeness using Redemption Outlook VBA and Custom Forms 2
A Creating Redemption.MAPIUtils failed with Windows 7 x64 Outlook VBA and Custom Forms 5
D href tags does not result in the full url with Redemption Outlook VBA and Custom Forms 4
E Redemption Foldes.Add doesn't work Outlook VBA and Custom Forms 3
E Redemption Foldes.Add doesn't work Outlook VBA and Custom Forms 3
N Redemption.RDOSession logon() stops emails sending-they stay in Ou Outlook VBA and Custom Forms 3
E Should I switch to redemption Outlook VBA and Custom Forms 11
E Should I switch to redemption Outlook VBA and Custom Forms 11
C Redemption - Rules for outlook Outlook VBA and Custom Forms 1
G Error in Outlook Object Model with redemption and google apps prem Outlook VBA and Custom Forms 3
S redemption reference Outlook VBA and Custom Forms 1
T Configure mailbox OutofOffice with Redemption Outlook Outlook VBA and Custom Forms 1
D redemption dll not registering in windows vista Outlook VBA and Custom Forms 3
Y Redemption MessageItem SaveAs problem Outlook VBA and Custom Forms 8
R Newbie Redemption ISafeMailItemPtr question Outlook VBA and Custom Forms 6
Q GAL.ResolveName issue with REDEMPTION Outlook VBA and Custom Forms 5
Q REDEMPTION HANGING during LOGON Outlook VBA and Custom Forms 2
P Redemption not working on OL2007 Outlook VBA and Custom Forms 2
S delete appointmentitem permanently using redemption Outlook VBA and Custom Forms 2
D redemption - foldercreate event + delegate user Outlook VBA and Custom Forms 8
C Assign To and CC list while using Redemption.dll library Outlook VBA and Custom Forms 10
U Re: Read fields with Redemption Outlook VBA and Custom Forms 1
V redemption MAPIUtils Outlook VBA and Custom Forms 3
C Synchronization and taking forever to send Using Outlook 2
D Send on behalf of does not store the base mailbox Using Outlook 0
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
S Outlook 2002- "Send" button has disappeared. Help please. Using Outlook 1
TomHuckstep Remove Send/Receive All Folders (IMAP/POP) button from Outlook 365 Ribbon Using Outlook 2
J Macro to send email as alias Outlook VBA and Custom Forms 0
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
W Outlook 365 I am getting the "Either there is no default mail client" error when I try to send an email on excel Office 365 Using Outlook 1
T Outlook 2010 recipient no longer shows in 'Send To' Using Outlook 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Geldner Tweak Junk Email Reporting tool to default to particular email on send? Using Outlook 3
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
L How to avoid issues with "Send on Behalf" Using Outlook 3
M Outlook 365 refuses to send email Using Outlook 0
A Change settings Send/receive VBA Outlook VBA and Custom Forms 0
M I cant send emails via Outlook in my W10 PC. Using Outlook 3
K Run a script rule to auto 'send again' on undeliverable emails? Outlook VBA and Custom Forms 1

Similar threads

Back
Top