Link to home
Start Free TrialLog in
Avatar of cin_champ
cin_champFlag for United States of America

asked on

VB.net 2010 how to send a email without having the user open outlook

Dear Experts,

Cant I get around this if so can you please enlighten the path for me?

This is what I have so far it works but user has to accept message (see attached)

Is there a way around this prompt?

 Dim olApp As Outlook.Application
        Dim olMail As Outlook.MailItem
        olApp = New Outlook.Application
        Try

            ' WORks but requires outlook to be open and user to accept

            ' Create a new MailItem.
            olMail = olApp.CreateItem(Outlook.OlItemType.olMailItem)
            olMail.Recipients.Add("test@test.com")
            olMail.Subject = "IMPORT SUMMARY"
            olMail.HTMLBody = "Attached  are Imported Files and Error Messages!!"""
            olMail.Attachments.Add("C:\test.txt", Outlook.OlAttachmentType.olByValue)
            olMail.Send()
            '
        Catch ex As Exception
            MessageBox.Show("Error File Import" & ex.Message)
            Dim mylogfilefile As System.IO.StreamWriter
            mylogfilefile = My.Computer.FileSystem.OpenTextFileWriter("c:\test.txt", True)
            mylogfilefile.WriteLine("" + ex.Message)
            mylogfilefile.Close()
        End Try
OutlookMessage.doc
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

You might give a look at the classes in the System.Net.Mail namespace namespace that goes around Outlook to send email. The documentation provides you with sample code.

Look at the documentation for the Attachment class for sample code that is very close to what you are trying to achieve with outlook.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cin_champ

ASKER

I think the links submitted my Emoreau are much more in depth so I will award all points