Home All Groups Group Topic Archive Search About

Sending Emails from Code

Author
5 Jan 2006 12:17 PM
Helen Trim
I have a program that sends emails automatically.  It works correctly, but
each time it sends an email, a message appears warning the user and they have
to wait 5 seconds for the Yes button to appear before they can click it. 
This is a bit annoying.

Is there an Outlook setting that will stop this message appearing?  Or can I
edit the code?

It is written in VB .Net:
Dim Email As New OutlookClass
Dim Message As Outlook.MailItem

Message = Email.OutlookApp.CreateItem(0)
Message.To = "Email address"
Message.Subject = "TCI Card "
Message.Body = "Text"
Message.Send()

Thanks,
Helen



--
Helen

Author
5 Jan 2006 12:27 PM
Herfried K. Wagner [MVP]
"Helen Trim" <HelenT***@discussions.microsoft.com> schrieb:
> I have a program that sends emails automatically.  It works correctly, but
> each time it sends an email, a message appears warning the user and they
> have
> to wait 5 seconds for the Yes button to appear before they can click it.
> This is a bit annoying.

I am curious why you are not using 'System.Web.Mail' (.NET 1.0/1.1) or
'System.Net.Mail' (.NET 2.0), which won't require Outlook to be installed.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
5 Jan 2006 1:50 PM
Helen Trim
Good point, Herfried.

It is a Windows application and I haven't found out yet how to send email
without using Outlook.

I'll keep looking but if you have any tips, I'd be very grateful.

Thanks
Helen
--
Helen


Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "Helen Trim" <HelenT***@discussions.microsoft.com> schrieb:
> > I have a program that sends emails automatically.  It works correctly, but
> > each time it sends an email, a message appears warning the user and they
> > have
> > to wait 5 seconds for the Yes button to appear before they can click it.
> > This is a bit annoying.
>
> I am curious why you are not using 'System.Web.Mail' (.NET 1.0/1.1) or
> 'System.Net.Mail' (.NET 2.0), which won't require Outlook to be installed.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
>
Author
5 Jan 2006 3:20 PM
Eric Moreau
You need to add a reference to system.web (even from a Windows application).

See http://www.systemwebmail.com/

--


HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
http://emoreau.s2i.com/

Show quoteHide quote
"Helen Trim" <HelenT***@discussions.microsoft.com> wrote in message
news:6B2872C6-99EC-4FFC-BBCE-A2DE261710E6@microsoft.com...
> Good point, Herfried.
>
> It is a Windows application and I haven't found out yet how to send email
> without using Outlook.
>
> I'll keep looking but if you have any tips, I'd be very grateful.
>
> Thanks
> Helen
> --
> Helen
>
>
> "Herfried K. Wagner [MVP]" wrote:
>
>> "Helen Trim" <HelenT***@discussions.microsoft.com> schrieb:
>> > I have a program that sends emails automatically.  It works correctly,
>> > but
>> > each time it sends an email, a message appears warning the user and
>> > they
>> > have
>> > to wait 5 seconds for the Yes button to appear before they can click
>> > it.
>> > This is a bit annoying.
>>
>> I am curious why you are not using 'System.Web.Mail' (.NET 1.0/1.1) or
>> 'System.Net.Mail' (.NET 2.0), which won't require Outlook to be
>> installed.
>>
>> --
>>  M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>>  V B   <URL:http://classicvb.org/petition/>
>>
>>
Author
5 Jan 2006 5:14 PM
lcifers
Add the reference as Heinfred pointed out. Here's a simple, but working
function.

    Private Function SendMail() As Boolean

        'Set up SMTP mail parameters
        Dim Email As New MailMessage
        Email.To = EmailTo 'String variable
        Email.From = EmailFrom 'String variable
        Email.Subject = EmailSubject 'String variable
        Email.Body = EmailBody 'String variable
        SmtpMail.SmtpServer = (SMTPServer) 'Name of your SMTP server

        'Send the mail
         SmtpMail.Send(Email)

    End Function