Solved

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

Posted on 2013-11-18
3
500 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 69

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now