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

  • SEARCH
  • Home
  • 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 8990379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:29:15+00:00 2026-06-15T22:29:15+00:00

I have a class to send emails with multiple attachments, it uses gmail, but

  • 0

I have a class to send emails with multiple attachments, it uses gmail, but how can I use Outlook to send emails?

   Imports System.Net.Mail
    Imports System.Net.Mime


    Public Sub SendThis(ByVal SubjectText As String, _
                             ByVal BodyText As String, _
                             ByVal FromAddress As String, _
                             ByVal ToAddress As String, _
                             Optional ByVal FileName As Collection = Nothing _
                             )
            Try
                Dim email As New Net.Mail.MailMessage(FromAddress, ToAddress)
                email.Subject = SubjectText
                email.Body = BodyText
                If Not FileName Is Nothing Then
                    For Each Name As String In FileName
                        Dim attach As New Net.Mail.Attachment(Name) 'Includes Path
                        email.Attachments.Add(attach)
                    Next
                    For Each At As Attachment In email.Attachments
                        At.TransferEncoding() = Net.Mime.TransferEncoding.Base64
                    Next
                End If
                Dim TheSmtp As New SmtpClient(YourSmtpServerName, 587)
                TheSmtp.Credentials = New Net.NetworkCredential("abc@gmail.com","MYPASS")
                TheSmtp.DeliveryMethod = SmtpDeliveryMethod.Network
                TheSmtp.Send(email)
                email.Attachments.Clear()
                TheSmtp = Nothing
                email = Nothing    
            Catch ex As Exception
                MessageBox.Show("Error: " & ex.Message, "HFB", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End Try
        End Sub

I call the function like:

      Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
            Dim BodyText As String
            Dim SubjectText As String
            Dim FromAddress As String
            Dim ToAddress As String
            Dim Filename As New Collection
            If Me.LstBxAttach.Items.Count > 0 Then
                For Each TheItem As String In LstBxAttach.Items
                    Filename.Add(TheItem)
                Next
            End If
            SubjectText = Me.TbSubject.Text
            BodyText = Me.TbBody.Text
            SendThis(SubjectText, _
                          BodyText, _
                          "from@example.com", _
                          "to@example.com", _
                          Filename _
                          )
            SubjectText = ""
            BodyText = ""
            FromAddress = ""
            ToAddress = ""
            MessageBox.Show("Sent!", "HFB", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Sub
  • 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-15T22:29:16+00:00Added an answer on June 15, 2026 at 10:29 pm

    You can use the Outlook object model. The Application object lets you connect to Outlook; to send an e-mail, you will want to create a MailItem object, populate the relevant properties, and call its Send method.

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

Sidebar

Related Questions

I have used the smtp class to send emails through code. Can I use
I have send an email using php mailer class. mail was sending successfully but
I have an Intent class to send multiple images to the email as an
i have already research on using the mail() to send to multiple recipient's but
What script, class or function you use to send many emails, excluding the in-built
I have been using this script to send emails to certain staff but because
It seems that when you use SmtpClient class and MailMessage to send emails, everything
I have a class named toto which I send to a function that does
I have a class the communicates with a device over TCP. I send commands,
In class 1 I have a hashmap which I send to my CustomAdapter. map.put(year,

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.