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
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