Outlook redemption send question/problem

  • Thread starter George Sambataro
  • Start date
G

George Sambataro

I am new to redemption object programming and while I have made progress, I
have a few problems/questions that hopefully someone can help out with.

I am testing on Outlook XP and I put together (with the help of info on the
internet) the attached code which is designed to send an email message.

When outlook is open on the desktop, the message only leaves the drafts
folder when the btn.execute is executed. The utils.delivernow does not seem
to work.

My main question is this.. Is this code supposed to work, and actually send
an email, when outlook is not running on the desktop?

When outlook is not running, I get a error 91,"object variable or with block
variable not set" on
Set btn = ol.ActiveExplorer.CommandBars.FindControl(1, 5488). I guess this
makes sense if outlook is not running. When I do open outlook I see that my
message is in the drafts folder. If it is supposed to be sent, when outlook
is not running, how can I make this happen?

Thanks for any help.

George


SendMail "test subject 33", "body of message2", "(e-mail address removed)", "", "",
""


Public Function SendMail(sSubj, sBody, sRecip, sRecipCc, sRecipBcc, sAttach)
Dim ol As Object ' added
Dim ns As Object
Dim newMail As Object
Dim SafeMail As Object
Dim btn As Object
Dim utils As Object

'Used to start Outlook
Set ol = CreateObject("Outlook.Application")

'Return a reference to the MAPI layer
Set ns = ol.GetNamespace("MAPI")
ns.Logon 'Added for Redemption

'Create a new mail message item
Set newMail = ol.CreateItem(0)
Set SafeMail = CreateObject("Redemption.SafeMailItem") '
SafeMail.Item = newMail 'Added for Redemption

With SafeMail
'Add the subject of the mail message
.Subject = (sSubj)
'Create some body text
.Body = (sBody)
'Do not save to Sent Items
.DeleteAfterSubmit = True

'Add a "To" recipient(optional)
If Len(sRecip) > 0 Then
With .Recipients.Add(sRecip)
.Type = 1
End With
End If

'Add a "Cc" recipient(optional)
If Len(sRecipCc) > 0 Then
With .Recipients.Add(sRecipCc)
.Type = 2
End With
End If

'Add a "Bcc" recipient(optional)
If Len(sRecipBcc) > 0 Then
With .Recipients.Add(sRecipBcc)
.Type = 3
End With
End If

'Attach a file as a link with an icon(optional)
If Len(sAttach) > 0 Then
With .Attachments.Add(sAttach)
End With
End If
End With

' send the email message

SafeMail.Recipients.ResolveAll

SafeMail.Send

' to force send
Set utils = CreateObject("Redemption.MAPIUtils")
utils.DeliverNow
' another way to force send
Set btn = ol.ActiveExplorer.CommandBars.FindControl(1, 5488)
btn.Execute


'Release memory
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
Set btn = Nothing
Set utils = Nothing

End Function
 

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