Solved

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

Posted on 2013-11-18
3
526 Views
Last Modified: 2013-11-22
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
0
Comment
Question by:cin_champ
3 Comments
 
LVL 40
ID: 39658326
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.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 39658441
0
 

Author Closing Comment

by:cin_champ
ID: 39669960
I think the links submitted my Emoreau are much more in depth so I will award all points
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question