Send With Redemption

B

bobdydd

Access 2000

I am using the following code to create an email and send it to my
Outlook 2000 Outbox..and everything works OK.

Since I have upgraded to Outlook 2003 there appears to be a set of
apostrophes around the email addresses.......which unless I am barking
up the wrong tree....marks the email as spam and causes my ISP to
reject and not send it.

If I manually type the same address directly into Outlook 2003 ...no
problem. So there must be some security in Outlook 2003 that adds the
apostrophes if another program tries to put and email directly into the
Outbox.

I can put it into the drafts folder........but I don't want to do that

Would the Redemption dll avoid this problem and how do I rewrite the
code below using Redemption.

Thanks for looking

Private Sub CmdEmail_Click()
'Declarations
Dim EmailTo As String
Dim Subject As String
Dim Contents As String
Dim OL As Outlook.Application
Dim OLNS As Outlook.NameSpace
Dim MailFolder As Outlook.MAPIFolder
Dim MyMail As Outlook.mailItem
Set OL = CreateObject("Outlook.Application")
Set MyMail = OL.CreateItem(olMailItem)
Set OLNS = OL.GetNamespace("MAPI")
Set MailFolder = OLNS.GetDefaultFolder(olFolderOutbox)


'Name Fields
EmailTo = Nz(Me!EmailTo, "") ' email address TO
Subject = Nz(Me!Subject, "") ' the subject of the email
Contents = Nz(Me!Body, "") ' the body of the email

'Prepare Mail
With MyMail
.To = EmailTo
.Subject = Subject
.Body = Body
.Send
End With

'Clean up Code
Exit_Here:
Set MailFolder = Nothing
Set OL = Nothing
Set OLNS = Nothing
Set MailFolder = Nothing
Set MyMail = Nothing
Exit Sub
End Sub
 
D

Dmitry Streblechenko

I don"t think I have ever heard of the apostrophes causing an e-maik to be
marked as spam.
Try the following change to see it it helps:

Set OL = CreateObject("Outlook.Application")
Set MailFolder = OLNS.GetDefaultFolder(olFolderOutbox)
OLNS.Logon
Set MailFolder = OLNS.GetDefaultFolder(olFolderOutbox)
Set MyMail = OL.CreateItem(olMailItem)
Set OLNS = OL.GetNamespace("MAPI")

dim sItem As Object
sItem = CreateObject("Redemption.SafeMailItem")
stem.Item = MyMail


'Name Fields
EmailTo = Nz(Me!EmailTo, "") ' email address TO
Subject = Nz(Me!Subject, "") ' the subject of the email
Contents = Nz(Me!Body, "") ' the body of the email

'Prepare stem
With MyMail
.Recipients.AddEx(EmailTo, EmailTo, "SMTP", olTo)
.Subject = Subject
.Body = Body
.Send
End With

'Clean up Code
Exit_Here:
Set MailFolder = Nothing
Set OL = Nothing
Set OLNS = Nothing
Set MailFolder = Nothing
Set MyMail = Nothing
Exit Sub
End Sub


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
B

bobdydd

Thanks for replying Dimitri

I have stripped the code down to basics and it almost works except it
put it in the "drafts" folder instead of the Outbox

Dim EmailTo As String
Dim Subject As String
Dim Contents As String
Dim OL As Outlook.Application
Dim MyMail As Redemption.SafeMailItem
Dim OLItem As Object
Dim safeItem As Redemption.SafeMailItem
Dim OLNS As Outlook.NameSpace
Dim MailFolder As Outlook.MAPIFolder

Set OL = CreateObject("Outlook.Application")
Set OLNS = OL.GetNamespace("MAPI")
Set MyMail = CreateObject("Redemption.SafeMailItem") 'Create
an Instance ofRedemption.SafeMailItem
Set OLItem = OL.CreateItem(0) 'Create a new message oItem
Set MailFolder = OLNS.GetDefaultFolder(olFolderOutbox)


'Prepare Mail
With MyMail
.Item = OLItem
.Recipients.Add ("(e-mail address removed)") 'only puts it
in drafts folder
.To = "(e-mail address removed)" 'FAULT can't assign vaule
to read only
.Subject = "Test Email"
.Body = "This email needs to go past the Security in
Outlook 2003"
.Send
End With

'Clean up Code
Exit_Here:
Set MailFolder = Nothing
Set OL = Nothing
Set OLNS = Nothing
Set MailFolder = Nothing
Set MyMail = Nothing
Exit Sub
 
D

Dmitry Streblechenko

You could've used

Set OLItem = OL.Session.GetDefaultFolder(olFolderOutbox).Items.Add

but Outlook would still put it in the Drafts folder. You need to move the
item to Outbox explicitly:

Set OLItem = OL.CreateItem(0)
Set OLItem = OLItem.Move(OL.Session.GetDefaultFolder(olFolderOutbox))

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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