Sending email via Outlook using C# and late binding

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have the following VB .NET code to send an e-mail with attachments via Outlook using late binding:
<div style="background-color:white; color:black
<pre><span style="color:blue Dim oApp <span style="color:blue As <span style="color:blue Object
<span style="color:blue Dim oMsg <span style="color:blue As <span style="color:blue Object
<span style="color:blue Dim oAttachs <span style="color:blue As <span style="color:blue Object
<span style="color:blue Dim oAttach <span style="color:blue As <span style="color:blue Object

oApp = CreateObject(<span style="color:#a31515 "Outlook.Application")
oMsg = oApp.CreateItem(0)<br/>oMsg.<span style="color:blue To = <span style="color:#a31515 mailto:me@abc.com"oMsg.Subject me@abc.com <br/>oMsg.Subject = <span style="color:#a31515 "This is the subject"
oMsg.Body = <span style="color:#a31515 "This is the body"<br/>
oAttachs = oMsg.Attachments

<span style="color:blue For i <span style="color:blue As <span style="color:blue Integer = 0 <span style="color:blue To UBound(sAttachments)
oAttach = oAttachs.Add(sAttachments(i), , oMsg.Body.Length + 1, sAttachments(i))
<span style="color:blue Next i

oMsg.Send()[/code]

I am struggling to convert this to C# code. All the examples Ive seen use early binding. I dont want this because early binding is dependent on the version of Outlook the client has installed (because I have to distribute the Outlook DLLs with the program)
and I want my app to function with any version of Outlook. Any ideas? Thanks...
<
Fabricio Rodriguez<br/>
Pretoria, South Africa

View the full article
 
Back
Top