Error in Outlook Object Model with redemption and google apps prem

G

Gpg

Hi all,


Y try to make a email as template. When template is done, i (try to) copying
and send it
Here is my code sample (i’ve added som messagebox for showing where is the
error…)

Private Sub test(ByVal destinataires As String, ByVal KeepTemplateMail As
Boolean)
Dim findOutlook As Boolean = False
Dim processes As Process() = Process.GetProcesses()
If processes.Length > 1 Then
Dim i As Integer = 0
For i = 0 To processes.Length - 1
If processes(i).ProcessName.ToUpper = "OUTLOOK" Then
findOutlook = True : i = processes.Length
Next
End If
If Not findOutlook Then Process.Start("Outlook.exe")


Dim OutlookApp As Outlook.Application = Nothing
Dim SafeMail As Redemption.SafeMailItem = Nothing
Dim SafeMailCopy As Redemption.SafeMailItem = Nothing
Try
OutlookApp = New Outlook.Application
SafeMail = New Redemption.SafeMailItem
SafeMail.Item =
OutlookApp.CreateItem(Outlook.OlItemType.olMailItem)
SafeMail.save()
Dim EntryId As String = SafeMail.Item.EntryId
SafeMail.display(True)
SafeMail = Nothing
OutlookApp = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

OutlookApp = New Outlook.Application
SafeMail = New Redemption.SafeMailItem

For Each item As Outlook.MailItem In
OutlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts).Items
SafeMail.Item = item
If SafeMail.Item.EntryId = EntryId Then
If MessageBox.Show("Sending template?", "Test",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
Windows.Forms.DialogResult.Yes Then
SafeMailCopy = New Redemption.SafeMailItem
MessageBox.Show("Copy template")

Try
SafeMailCopy.Item = SafeMail.Item.copy()
MessageBox.Show("Copy template ok")
Catch ex As System.Exception
MessageBox.Show("Copy template ko")
Exit For
End Try
SafeMailCopy.Item.to = str
SafeMailCopy.Item.CC = ""
SafeMailCopy.Item.BCC = ""
MessageBox.Show("Save template")
SafeMailCopy.save()
MessageBox.Show("Save template ok")
MessageBox.Show("Send template")
SafeMailCopy.Send()
MessageBox.Show("Send template ok")
SafeMailCopy = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
If Not KeepTemplateMail Then SafeMail.Item.delete()
Exit For
End If
Next
Catch ex As System.Exception : Messagebox.Show(ex.Message)
Finally
SafeMailCopy = Nothing
SafeMail = Nothing
OutlookApp = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
End Sub

So, this red line fork perfectly with outlook connected to exchange or Gmail
(throught IMAP) and not with GoogleAppsPremier and GoogleAppsSync.

An error like « Unable to complete the operation because the service
provider does not support. » Is throwed.

i've already contacted Dmitry and he's respond that's this error come from
the Outlook Object Model and not from Redemption

So, witch difference are in this Model? how to turn around that?

Thank's in advance

Excuse me for my pitiful English

Gpg
 
E

Eric Legault [MVP - Outlook]

Where exactly are you getting the error? Can you add more error handling
around the .Save and .Send methods to narrow it down?

Also, why are you calling "OutlookApp = New Outlook.Application" twice?
This may be excessive and could contribute to your problems.

What is the purpose of your code anyway?
 
G

Gpg

Hi Eric,

thank's for your quickly response

the error is in "SafemailCopy.item = safemail.item.copy"
the message throwed is "Unable to complete the operation because the service
provider does not support."

i call "OutlookApp = New Outlook.Application" twice because i need to
display and retrieve the template email and without freeing and regrab the
template, outlook doesn't store and display correctly his content.

i've also discused about this with Dmitry Streblechenko and it' seem that's
an Outlook Model Object Error. i user Google Apps Premier, with a mapi
support for outlook, but i not know how it's work, what is comming from
outlook and what is comming from google apps

so, i'm in trouble...

with exchange, it's work fine
 
D

Dmitry Streblechenko

It simply looks like the MAPI message store provider provided by Google does
not support that functionality

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

jam

Eric said:
Where exactly are you getting the error? Can you add more error handling
around the .Save and .Send methods to narrow it down?

Also, why are you calling "OutlookApp = New Outlook.Application" twice?
This may be excessive and could contribute to your problems.

What is the purpose of your code anyway?

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
E

efr

Eric said:
Where exactly are you getting the error? Can you add more error handling
around the .Save and .Send methods to narrow it down?

Also, why are you calling "OutlookApp = New Outlook.Application" twice?
This may be excessive and could contribute to your problems.

What is the purpose of your code anyway?

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 

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