How implement SendTo Mail Recipient?

  • Thread starter Thread starter Ed Sutton
  • Start date Start date
E

Ed Sutton

I found a C++ article that talks about drop targets and sendmail.dll. It
shows an example that works like the PowerToys SendTo Mail Recipient shell
extension.

http://www.codeproject.com/useritems/sendtomail.asp

How can this be done in DotNet?

I want to create an attachment, attach it to an e-mail, and popup the user's
Outlook or Outlook Express so the user can then select an address.

Thanks in advance,

-Ed
 
Hello Ed,

You are probably looking for the Microsoft Outlook 11.0 Object Library. You can add a reference to this dll under the COM tab in the Add References
dialog.

Also, to get you started, here is a sample Windows Application written in .NET:

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(240, 8)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Send"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(8, 8)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(192, 20)
Me.TextBox1.TabIndex = 1
Me.TextBox1.Text = ""
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(208, 8)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(24, 23)
Me.Button2.TabIndex = 2
Me.Button2.Text = "..."
'
'OpenFileDialog1
'
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(328, 38)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim olApp As New Outlook.Application
Dim olMailMessage As Outlook.MailItem = olApp.CreateItem(Outlook.OlItemType.olMailItem)
olMailMessage.Subject = "A message from Visual Basic!"
olMailMessage.Body = "Here is a simple message with an attachment." & Environment.NewLine & _
"It was created using Visual Basic.NET and the Microsoft Outlook 11.0 Object Library."
olMailMessage.Attachments.Add(TextBox1.Text)
olMailMessage.Display()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.ShowDialog()
End Sub

Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles
OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub
End Class


--------------------
 
Back
Top