Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-11-18
3
Medium Priority
?
619 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

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)…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

705 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