Sending Emails from Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 Trim said:
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.
 
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
 
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
 

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

Back
Top