Outlook Redemption, Again

J

John

Hi

Does anyone have a vb.net example of how to use redemption to send mail
through outlook?

Many Thanks

Regards
 
H

Helmut Obertanner

Hi,

normal i code in c#, but here is a translation to vb.net:
i created an Interop dll with tlbimp for Redemption

see article:
http://msdn.microsoft.com/library/d.../html/cpconimportingtypelibraryasassembly.asp

Imports Microsoft.Office.Interop.Outlook

Imports RedemptionNet

Class MyApp

Public Shared Sub Main()

Dim objApp As Microsoft.Office.Interop.Outlook.Application

Dim objNS As Microsoft.Office.Interop.Outlook.NameSpace

Dim objSafeItem As RedemptionNet.SafeMailItem

Dim objMailItem As Microsoft.Office.Interop.Outlook.MailItem

objApp = New Application

objNS = objApp.GetNamespace("MAPI")

objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)

objSafeItem = New SafeMailItem

objSafeItem.Item = objMailItem

objSafeItem.Recipients.Add("(e-mail address removed)")

objMailItem.Subject = "TestMessage"

objSafeItem.Body = "TestMessage"

objSafeItem.Send()

objSafeItem = Nothing

objMailItem = Nothing

objNS.Logoff()

objNS = Nothing

objApp = Nothing



End Sub

End Class



--
--
regards,
Helmut Obertanner
DATALOG Software AG
http://www.datalog.de
[obertanner at datalog dot de]
 
J

John

Hi Helmut

Many thanks for that. I added outlook 10 and redemption.dll references under
COM. Would this not be enough for vs.net to automatically generate interop
dlls?

My code with slight modifications is given below. I am getting the error at
the specified line. Any idea what I am doing wrong?

Thanks

Regards


Imports Outlook
Imports Redemption

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objSafeItem As Redemption.SafeMailItem
Dim objMailItem As Outlook.MailItem

objApp = New Application
objNS = objApp.GetNamespace("MAPI")
objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)
objSafeItem = New SafeMailItem
objSafeItem.Item = objMailItem
objSafeItem.Recipients.Add("(e-mail address removed)")
objMailItem.Subject = "TestMessage"
objSafeItem.Body = "TestMessage"
objSafeItem.Send() ' <=== ERROR HERE:
System.Runtime.InteropServices.COMException (0x80040607): Could not submit
the message - error 0x80040607

objSafeItem = Nothing
objMailItem = Nothing
objNS.Logoff()
objNS = Nothing
objApp = Nothing
End Sub
End Class

Helmut Obertanner said:
Hi,

normal i code in c#, but here is a translation to vb.net:
i created an Interop dll with tlbimp for Redemption

see article:
http://msdn.microsoft.com/library/d.../html/cpconimportingtypelibraryasassembly.asp

Imports Microsoft.Office.Interop.Outlook

Imports RedemptionNet

Class MyApp

Public Shared Sub Main()

Dim objApp As Microsoft.Office.Interop.Outlook.Application

Dim objNS As Microsoft.Office.Interop.Outlook.NameSpace

Dim objSafeItem As RedemptionNet.SafeMailItem

Dim objMailItem As Microsoft.Office.Interop.Outlook.MailItem

objApp = New Application

objNS = objApp.GetNamespace("MAPI")

objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)

objSafeItem = New SafeMailItem

objSafeItem.Item = objMailItem

objSafeItem.Recipients.Add("(e-mail address removed)")

objMailItem.Subject = "TestMessage"

objSafeItem.Body = "TestMessage"

objSafeItem.Send()

objSafeItem = Nothing

objMailItem = Nothing

objNS.Logoff()

objNS = Nothing

objApp = Nothing



End Sub

End Class



--
--
regards,
Helmut Obertanner
DATALOG Software AG
http://www.datalog.de
[obertanner at datalog dot de]



John said:
Hi

Does anyone have a vb.net example of how to use redemption to send mail
through outlook?

Many Thanks

Regards
 
H

Helmut Obertanner

Hi,

1 st, if you using the redemtion.dll -> it's a com dll.
you can use com dll's in .net directly, but you have you release the objects
manually.
in c# it's like System.Interop.Marshal.ReleaseComObject(object)

if you generate a WrapperDll, you don't have to deal with unmanaged code.

2.

Maybe you using the wrong credentials.
objNS.Logon("Outlook", "Password Here", False, False)

I get no error, but i noticed, that the email is in my drafts folder.

--
regards,
Helmut Obertanner
DATALOG Software AG
http://www.datalog.de
[obertanner at datalog dot de]


John said:
Hi Helmut

Many thanks for that. I added outlook 10 and redemption.dll references under
COM. Would this not be enough for vs.net to automatically generate interop
dlls?

My code with slight modifications is given below. I am getting the error at
the specified line. Any idea what I am doing wrong?

Thanks

Regards


Imports Outlook
Imports Redemption

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objSafeItem As Redemption.SafeMailItem
Dim objMailItem As Outlook.MailItem

objApp = New Application
objNS = objApp.GetNamespace("MAPI")
objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)
objSafeItem = New SafeMailItem
objSafeItem.Item = objMailItem
objSafeItem.Recipients.Add("(e-mail address removed)")
objMailItem.Subject = "TestMessage"
objSafeItem.Body = "TestMessage"
objSafeItem.Send() ' <=== ERROR HERE:
System.Runtime.InteropServices.COMException (0x80040607): Could not submit
the message - error 0x80040607

objSafeItem = Nothing
objMailItem = Nothing
objNS.Logoff()
objNS = Nothing
objApp = Nothing
End Sub
End Class

Helmut Obertanner said:
Hi,

normal i code in c#, but here is a translation to vb.net:
i created an Interop dll with tlbimp for Redemption

see article:
http://msdn.microsoft.com/library/d.../html/cpconimportingtypelibraryasassembly.asp
Imports Microsoft.Office.Interop.Outlook

Imports RedemptionNet

Class MyApp

Public Shared Sub Main()

Dim objApp As Microsoft.Office.Interop.Outlook.Application

Dim objNS As Microsoft.Office.Interop.Outlook.NameSpace

Dim objSafeItem As RedemptionNet.SafeMailItem

Dim objMailItem As Microsoft.Office.Interop.Outlook.MailItem

objApp = New Application

objNS = objApp.GetNamespace("MAPI")

objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)

objSafeItem = New SafeMailItem

objSafeItem.Item = objMailItem

objSafeItem.Recipients.Add("(e-mail address removed)")

objMailItem.Subject = "TestMessage"

objSafeItem.Body = "TestMessage"

objSafeItem.Send()

objSafeItem = Nothing

objMailItem = Nothing

objNS.Logoff()

objNS = Nothing

objApp = Nothing



End Sub

End Class



--
--
regards,
Helmut Obertanner
DATALOG Software AG
http://www.datalog.de
[obertanner at datalog dot de]



John said:
Hi

Does anyone have a vb.net example of how to use redemption to send mail
through outlook?

Many Thanks

Regards
 
J

John

Hi Helmut

Not sure where to go from here. Marshalling isn't my strong point. :)

My full project, dlls and all, is in the email. It was too large to post
here. Would appreciate if you can pin point the problem.

Thanks

Regards

Helmut Obertanner said:
Hi,

1 st, if you using the redemtion.dll -> it's a com dll.
you can use com dll's in .net directly, but you have you release the objects
manually.
in c# it's like System.Interop.Marshal.ReleaseComObject(object)

if you generate a WrapperDll, you don't have to deal with unmanaged code.

2.

Maybe you using the wrong credentials.
objNS.Logon("Outlook", "Password Here", False, False)

I get no error, but i noticed, that the email is in my drafts folder.

--
regards,
Helmut Obertanner
DATALOG Software AG
http://www.datalog.de
[obertanner at datalog dot de]


John said:
Hi Helmut

Many thanks for that. I added outlook 10 and redemption.dll references under
COM. Would this not be enough for vs.net to automatically generate interop
dlls?

My code with slight modifications is given below. I am getting the error at
the specified line. Any idea what I am doing wrong?

Thanks

Regards


Imports Outlook
Imports Redemption

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objSafeItem As Redemption.SafeMailItem
Dim objMailItem As Outlook.MailItem

objApp = New Application
objNS = objApp.GetNamespace("MAPI")
objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)
objSafeItem = New SafeMailItem
objSafeItem.Item = objMailItem
objSafeItem.Recipients.Add("(e-mail address removed)")
objMailItem.Subject = "TestMessage"
objSafeItem.Body = "TestMessage"
objSafeItem.Send() ' <=== ERROR HERE:
System.Runtime.InteropServices.COMException (0x80040607): Could not submit
the message - error 0x80040607

objSafeItem = Nothing
objMailItem = Nothing
objNS.Logoff()
objNS = Nothing
objApp = Nothing
End Sub
End Class
http://msdn.microsoft.com/library/d.../html/cpconimportingtypelibraryasassembly.asp
Imports Microsoft.Office.Interop.Outlook

Imports RedemptionNet

Class MyApp

Public Shared Sub Main()

Dim objApp As Microsoft.Office.Interop.Outlook.Application

Dim objNS As Microsoft.Office.Interop.Outlook.NameSpace

Dim objSafeItem As RedemptionNet.SafeMailItem

Dim objMailItem As Microsoft.Office.Interop.Outlook.MailItem

objApp = New Application

objNS = objApp.GetNamespace("MAPI")

objNS.Logon("Outlook", "", False, False)

objMailItem = objApp.CreateItem(OlItemType.olMailItem)

objSafeItem = New SafeMailItem

objSafeItem.Item = objMailItem

objSafeItem.Recipients.Add("(e-mail address removed)")

objMailItem.Subject = "TestMessage"

objSafeItem.Body = "TestMessage"

objSafeItem.Send()

objSafeItem = Nothing

objMailItem = Nothing

objNS.Logoff()

objNS = Nothing

objApp = Nothing



End Sub

End Class



--
--
regards,
Helmut Obertanner
DATALOG Software AG
http://www.datalog.de
[obertanner at datalog dot de]



Hi

Does anyone have a vb.net example of how to use redemption to send mail
through outlook?

Many Thanks

Regards
 

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