Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:26:27+00:00 2026-06-12T05:26:27+00:00

‘Variable which will send the mail Dim obj As System.Net.Mail.SmtpClient ‘Variable to store the

  • 0
 'Variable which will send the mail
Dim obj As System.Net.Mail.SmtpClient

'Variable to store the attachments 
Dim Attachment As System.Net.Mail.Attachment

'Variable to create the message to send
Dim Mailmsg As New Mail.MailMessage()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Try

        Dim ol As New Outlook.Application()
        Dim ns As Outlook.NameSpace
        Dim fdMail As Outlook.MAPIFolder

        ns = ol.GetNamespace("MAPI")
        ns.Logon(, , True, True)

        'creating a new MailItem object
        Dim newMail As Outlook.MailItem

        'gets defaultfolder for my Outlook Outbox
        fdMail = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)



        'assign values to the newMail MailItem
        newMail = fdMail.Items.Add(Outlook.OlItemType.olMailItem)
        newMail.Subject = "tesst"
        newMail.Body = "test"
        newMail.To = TextBox1.Text
        Dim sSource As String = Application.StartupPath + "\kk.sys"
        ' TODO: Replace with attachment name
        Dim sDisplayName As String = "kaar.jpg"

        Dim sBodyLen As String = newMail.Body.Length


        newMail.SaveSentMessageFolder = fdMail

        newMail.Send()

    Catch ex As Exception


        Using writer As StreamWriter = New StreamWriter(Application.StartupPath + "\err1.txt")

            writer.WriteLine(ex.ToString)



        End Using

    End Try

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Try
        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()
        Dim address As New MailAddress(TextBox1.Text, "Nigraan")
        Dim oAttch As Mail.Attachment = New Mail.Attachment(Application.StartupPath + "\kk.sys")
        SmtpServer.Credentials = New  _
Net.NetworkCredential(TextBox2.Text, TextBox3.Text)
        SmtpServer.Port = "587"
        SmtpServer.Host = "smtp.gmail.com"
        mail = New MailMessage()
        mail.From = New MailAddress(TextBox2.Text)
        mail.To.Add(New MailAddress(TextBox1.Text))
        mail.Subject = TextBox3.Text
        mail.Body = "test"


        mail.Attachments.Add(oAttch)

        SmtpServer.Send(mail)

    Catch ex As Exception

        Using writer As StreamWriter = New StreamWriter(Application.StartupPath + "\err2.txt")

            writer.WriteLine(ex.ToString)



        End Using
    End Try
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    Try
        System.Diagnostics.Process.Start("mailto:" & TextBox1.Text & "?subject=" & "re:Subject" & "&body=" & "EmailBody")
    Catch ex As Exception

        Using writer As StreamWriter = New StreamWriter(Application.StartupPath + "\err3.txt")

            writer.WriteLine(ex.ToString)



        End Using
    End Try
End Sub`

errors are:

err1:

System.Runtime.InteropServices.COMException (0x80004005): There must be at least one name or distribution list in the To, Cc, or Bcc box.
at Microsoft.Office.Interop.Outlook._MailItem.Send()
at WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e)

err2:

System.ArgumentException: The parameter ‘address’ cannot be an empty string.
Parameter name: address
at System.Net.Mail.MailAddress..ctor(String address, String displayName, Encoding displayNameEncoding)
at WindowsApplication1.Form1.Button2_Click(Object sender, EventArgs e)

When i send using a machine with visual studio both mail gets sent, when not these errors show.

i have double checked .net framework

thank you..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:26:28+00:00Added an answer on June 12, 2026 at 5:26 am

    i got everything working,

    got smtp to work by giving ssl encryption to true

    got outlook to work by creating a contact and giving the contact’s email id in the ‘to’ field

    just don’t save the contact if u don’t want the contact to be added in outlook 😀

    yeyyy!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a RegEx expression that will successfully parse the following
I was writing code for dragging mechanism which invokes to wait for small period
I'm running a Octopress blog which is based on Jekyll . Now I wanted
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
The problem with unsigned char. I am reading a PPM image file which has
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.