Home All Groups Group Topic Archive Search About

Sending an Email from .net?

Author
12 May 2006 7:16 AM
rj
Hi All,

How do i send an email from a vb.net form? I have a text box with the
email address, another with the email body, and I want to use standard
text for the subject. Is there a way for me to automatically open a
"new mail form" from outlook, and automatically put these values in?

Thanks in advance..

Author
12 May 2006 9:36 AM
Pieter Coucke
Public Sub NewMail(ByVal strTo As String, Optional ByVal strSubject As
String = "", Optional ByVal strMessage As String = "", Optional ByVal
colAttachments As Collection = Nothing)
        Try
            Dim oApp As Outlook.Application
            oApp = New Outlook.Application
            MailObject = oApp.CreateItem(Outlook.OlItemType.olMailItem)

            With MailObject
                'ATTACHMENTS!!!!
                Dim intX As Integer
                If colAttachments IsNot Nothing Then
                    For intX = 1 To colAttachments.Count
                        .Attachments.Add(colAttachments(intX),
Outlook.OlAttachmentType.olByValue)
                    Next
                End If

                .Subject = strSubject
                .To = strTo

                .Body =strMessage

                'Send it directly!
                '.Send()
                'Open it!
                .Display()

            End With
            oApp = Nothing
        Catch ex As Exception
            Throw ex
        Finally
        End Try
    End Sub


A reference must be added to Outlook...

Show quoteHide quote
"rj" <rje***@gmail.com> wrote in message
news:1147418210.174844.211100@g10g2000cwb.googlegroups.com...
> Hi All,
>
> How do i send an email from a vb.net form? I have a text box with the
> email address, another with the email body, and I want to use standard
> text for the subject. Is there a way for me to automatically open a
> "new mail form" from outlook, and automatically put these values in?
>
> Thanks in advance..
>
Author
12 May 2006 9:47 AM
Herfried K. Wagner [MVP]
"rj" <rje***@gmail.com> schrieb:
> How do i send an email from a vb.net form? I have a text box with the
> email address, another with the email body, and I want to use standard
> text for the subject. Is there a way for me to automatically open a
> "new mail form" from outlook, and automatically put these values in?

Opening files, applications, Web documents, and the mail client
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=openfileappwebpage&lang=en>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
12 May 2006 11:49 AM
Cor Ligthert [MVP]
rj,

A simple sample

http://www.vb-tips.com/default.aspx?ID=549ce1f6-c497-4ad5-950f-9dd3d7bb8e60

be aware that we have some problems with our new website

Cor

Show quoteHide quote
"rj" <rje***@gmail.com> schreef in bericht
news:1147418210.174844.211100@g10g2000cwb.googlegroups.com...
> Hi All,
>
> How do i send an email from a vb.net form? I have a text box with the
> email address, another with the email body, and I want to use standard
> text for the subject. Is there a way for me to automatically open a
> "new mail form" from outlook, and automatically put these values in?
>
> Thanks in advance..
>