Sending email with attachment

R

ReidarT

I got som pretty good help with code for sending emails to 3 persons from
Ken Tucker.
What I miss now is how to send an attachment with the email.
regards
reidarT
 
K

Ken Tucker [MVP]

Hi,

butnSendMail.Enabled = False

Try

Dim LMsg As New Indy.Sockets.IndyMessage.Message

LMsg.From.Text = textFrom.Text.Trim()

LMsg.Recipients.Add().Text = "(e-mail address removed)"

LMsg.Subject = textSubject.Text.Trim()

LMsg.Body.Text = textMsg.Text

Dim indyFile As New _

Indy.Sockets.IndyAttachmentFile.AttachmentFile(LMsg.MessageParts, _

"C:\test.txt")



Dim LSMTP As New SMTP

AddHandler LSMTP.OnStatus, AddressOf SMTPStatus

LSMTP.Host = "sendmail.YourServer.com"

LSMTP.Username = "UserName"

LSMTP.Password = "YourPassword"

LSMTP.Connect()

Try

LSMTP.Send(LMsg)

Status("Completed")

Finally

LSMTP.Disconnect()

End Try

Finally

butnSendMail.Enabled = True

End Try



Ken

-----------------------

I got som pretty good help with code for sending emails to 3 persons from
Ken Tucker.
What I miss now is how to send an attachment with the email.
regards
reidarT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top