The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 10:30am (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 10:30am (PST)
Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Sending inbound e-mail using vb.net

Highlighted
NMOLL
Regular Collector

Sending inbound e-mail using vb.net

Hi guys,

I have problem with sending inbound email by using a vb.net application. The problem is that attachments are saved as content.txt.

If I send the mail to my own email address and then forward it to HPSD, the attachment is stored correctly. My guess is that something is wrong with my code.

Anyone able to help?
==============================================
Copy of my vb.net code:
-----------------------
Imports System.Net.Mail

Dim mail As New MailMessage()
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("hpsd@mycompany.com")

' -- Subject
mail.Subject = "Mail subject"

' -- Body
mail.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-1")
mail.Body = "This is the mail body text"

' -- Attachment
Dim attach As New Attachment("c:\test.xls")
attach.ContentDisposition.DispositionType = System.Net.Mime.DispositionTypeNames.Attachment
Mail.Attachments.Add(attach)

' -- SMTP
Dim smtp As New SmtpClient("smtp.mycompany.com")

smtp.Send(mail)
1 REPLY
chan_lemo
Acclaimed Contributor
//Add this to "OnDomLoad" event