Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I�m a student studding the DOT Net framework we are currently working in V.B.

 

I would like to build a program that will send an email with an attachment (like a picture) can anyone get me started in the right direction.

 

I don�t know if you can send email directly from a V.B program or if I must link to Outlook?

 

Can someone tell me where to find the commands and the Syntax.

 

Thanks for any help

Posted

Sending email is a nice feature in .NET.

 

First you'll want to add a reference to system.web.mail.

 

then add some code simliar to this:

 

Dim objEmailMessage As System.Web.Mail.MailMessage
       Dim objSMTPServer As System.Web.Mail.SmtpMail

       objEmailMessage = New System.Web.Mail.MailMessage
       With objEmailMessage
           .To = "me@mydomain.com"
           .From = "bill.gates@microsoft.com"
           .Subject = "Great Job!"
           .Body = "Want all my money?"
       End With

       objSMTPServer.Send(objEmailMessage)

 

You can specify a specific SMTP server if required, and you can add attachments using the attachments property.

 

This should give you a good enough start.

 

Sam.

Posted
Thanks everyone for all the help I have worked on this and everything is working fine I will need to modify the code provided by (samsmithnz) (Tanks by the way) But it seems to work just like it is. When I run it I see my outgoing email scanner go off but I never receive an email I changed the code to my email address but still get nothing. The only thing I can think of is that I have specified an SMTP server. Can anyone help???
Posted (edited)

no and I will be puting this program on another machine so I really need to be abel to specafy the smtp server.

 

I really need to beable to use a smtp sever like comcast

 

(smtp.comcast.net)

 

This project is for the Museum of Flight In Seattle what it�s going to do is take a picture of the user (

With a webcam) and email that to anyone the user specifies.

 

I t will work a lot like the one at the Microsoft Museum if you have ever seen that one. I probably could have just got that one but then I wouldn�t have learned anything and that is what this is all about. I�m not making any money just a project for School.

 

Thanks for any additional halp

Edited by Mike Bailey
  • *Experts*
Posted
If you don't have a SMTP server on the client computer then what you could do is maybe set up an email hosting/website hosting and use the server name that would be provided. Like email.yourdmain.com. Works for me with the email server provided by my webhost.
Posted (edited)

Now I'm getting this

 

 

The messeage comes when it runs the last line of code

 

Hers my code

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim objEmailMessage As System.Web.Mail.MailMessage
       Dim objSMTPServer As System.Web.Mail.SmtpMail

       objEmailMessage = New System.Web.Mail.MailMessage
       With objEmailMessage
           .To = txtToEmail.Text
           .From = txtFrom.Text
           .Subject = "Great Job!"
           .Body = "Want all my money?"
       End With

      [color=red] objSMTPServer.Send(objEmailMessage)[/color]


  
   End Sub
End Class

When the code that is in red is ran I get this error

 

An unhandled exception of type 'System.Web.HttpException' occurred in system.web.dll

Additional information: Could not access 'CDO.Message' object.

Edited by Mike Bailey
Posted

Add a line jsut before you send the email, I don't have VS.NEt open right here, but if you type in objSMTPServer and then a dot, you can select a STMPSERVER property (or something like that), and add "smtp.comcast.com".

 

That error you're receiving is a roundabout way of saying you don't have smtp confgiured on your computer. I recommend you select MailMessage and SmtpMail in your code and press F1 to get an overview of what each class actually does.

 

Sam

Posted

objSMTPServer.smtpserver = "smtp.comcast.net"

 

:)

This is only a test of the emergency broadcast system

This is a product of hysterical mass confusion

A ship of fools adrift on the sea of our pollution

Rudderless and powerless on the sea of our delusion

pennywise - this is only a test

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...