Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-11-18
3
Medium Priority
?
640 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

916 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