By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,636 Members | 1,915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,636 IT Pros & Developers. It's quick & easy.

Create Email, attach file and send using default mail client ...

P: n/a
Hello,

Is there a way of creating an email, attaching a file and sending using the
client's default mail client?

I am looking for a none email client specific solution that does not involve
specifying parameters such as mail servers etc.

Cheers,

Landers
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Landley,

Almost, but you have to have an smtp server reference, or else the system
does not know what it is. You could find some esoteric way to query the
current accounts inside Outlook or Outlook Express, but even the query
wouldn't know if that were a valid smtp server.

Here's the easiest way to do it:
Begin your class with a reference to system.web.mail:
Imports System.Web.Mail

Then add the code as appropriate:
Dim msg As New MailMessage

msg.To = "be*****@xxxx.net"

msg.From = "MN***@xxxxx.com"

msg.Subject = "test subject"

Dim astring1 As String = "c:\my documents\wzo letter.doc"

msg.Attachments.Add(New MailAttachment(astring1))

Dim astring2 As String = "c:\my documents\visual basic notes.doc"

msg.Attachments.Add(New MailAttachment(astring2))

Dim astring3 As String = "\\imcsql\data\imcapps\sqldiag.txt"

msg.Attachments.Add(New MailAttachment(astring3))

msg.Cc = "we*******@xxxxx.com"

SmtpMail.SmtpServer = "mail.xxxxx.com"

Try

SmtpMail.Send(msg)

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

HTH,

Bernie Yaeger

"Landley" <ne**@creations-software.co.uk> wrote in message
news:u$**************@TK2MSFTNGP11.phx.gbl...
Hello,

Is there a way of creating an email, attaching a file and sending using
the
client's default mail client?

I am looking for a none email client specific solution that does not
involve
specifying parameters such as mail servers etc.

Cheers,

Landers

Nov 21 '05 #2

P: n/a
Landley,

Not using the default mail client in the way you said, when you are sure
that is Office Outlook than you can using the interop too that.

For sending mail with attachment, you can use Bernie's sugestion, however
be aware that for that you should have at least NT5x clients and the mail is
not saved in the users mailclient.

When you search this newsgroup you will find tons of questions about this.

Cor

"Landley"
Hello,

Is there a way of creating an email, attaching a file and sending using
the
client's default mail client?

I am looking for a none email client specific solution that does not
involve
specifying parameters such as mail servers etc.

Cheers,

Landers

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.