Results 1 to 5 of 5

Thread: Unable to send an Email from VB.Net

  1. #1
    Join Date
    Dec 2008
    Posts
    19

    Unable to send an Email from VB.Net

    Hi,

    I want to send an email from a VB.Net 2005 application. we use Exchange Server, But then I want it to send the email without user intervention.
    How can I get this to work in .Net, or is there a better way to send an email from .Net, without user intervention?

    Thanks,

  2. #2
    Join Date
    Dec 2008
    Posts
    2

    Re: Unable to send an Email from VB.Net

    If you don't have SMTP in Exchange Server...

    I am not sure, do you want to send mail through outlook?

    Try this snippet

    Dim AppOutlook As Object
    Dim OutlookMessage As Object
    Const MailItem = 0
    Const RCType = 1
    AppOutlook = CreateObject("Outlook.Application")
    OutlookMessage = AppOutlook.CreateItem(MailItem)
    With OutlookMessage
    Dim Recipent As Object = .Recipients.Add("myemail@hotmail.com")
    Recipent.type = RCType
    .Subject = "Sending through Outlook"
    .Body = "Testing outlook Mail"
    .Send()
    End With
    OutlookMessage = Nothing
    AppOutlook = Nothing

  3. #3
    Join Date
    Dec 2008
    Posts
    19

    Re: Unable to send an Email from VB.Net

    I have looked into this carefully, and found two problems with this approach. First, I get the system exception whenever Outlook is running in background. I cannot prohibit my users from using Outlook at the same time as they use this application.
    But when I am not running Outlook, I get another error at the Dim Recipient as Object line, "Operation aborted (exception from HRESULT: 0x8000400 (E_ABORT))".

    so what to do for that?

  4. #4
    Join Date
    Dec 2008
    Posts
    2

    Re: Unable to send an Email from VB.Net

    ok i have a another way to do this, just follow the bellow steps.

    1 Go to Project Add Reference and in .net tab find Microsoft.Office.Interop.Outlook and press ok

    2.

    Imports outlook = Microsoft.Office.Interop.Outlook
    Public Class Form1
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim AppOutlook As New outlook.Application
    Dim OutlookMessage As outlook.MailItem = AppOutlook.CreateItem(outlook.OlItemType.olMailItem)
    AppOutlook = CreateObject("Outlook.Application")
    Dim Recipents As outlook.Recipients = OutlookMessage.Recipients
    Recipents.Add("myemail@hotmail.com")
    OutlookMessage.Subject = "Sending through Outlook"
    OutlookMessage.Body = "Testing outlook Mail"
    OutlookMessage.Send()
    OutlookMessage = Nothing
    AppOutlook = Nothing
    End Sub
    End Class

  5. #5
    Join Date
    Dec 2008
    Posts
    19

    Re: Unable to send an Email from VB.Net

    Thanks for the new code! this works properly.

Similar Threads

  1. Unable to send email from my Blackberry to HP ePrint
    By Ekachakrya in forum Portable Devices
    Replies: 6
    Last Post: 27-11-2011, 11:28 AM
  2. Replies: 4
    Last Post: 23-08-2011, 08:04 AM
  3. Replies: 6
    Last Post: 10-07-2011, 08:26 PM
  4. Unable to send email in iPhone
    By Burt/Bert in forum Portable Devices
    Replies: 5
    Last Post: 24-02-2011, 11:40 AM
  5. Unable to send pictures via email
    By Dheran in forum Technology & Internet
    Replies: 3
    Last Post: 04-02-2009, 04:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,278,918.04354 seconds with 17 queries