It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Receiving email with VB.NET

Moderator: dafunkymunky

Receiving email with VB.NET

Postby cipango on Fri Oct 08, 2004 8:36 pm

I am researching this topic without a satisfactory solution so far.
Please let me know which is the easiest way to receive email using VB code. All I need is to test source address or subject line for the right email, and then click a link inside that email.
I've seen some people suggested MAPI component, but it's missing in my complete components list (not only in the toolbar). But I see an Outlook Express component, which I suspect is easier to use than Outlook or CDO objects. Anyway, I am looking for something that will be available on any machine, and not only on one with Outlook installed.
cipango
 
Posts: 3
Joined: Fri Oct 08, 2004 8:27 pm

check this way

Postby techyashish on Fri Oct 08, 2004 8:45 pm

Imports System.Web.Mail
Within the Class declaration, in the general section, declare variables required for this project.

' Variable which will send the mail
Dim obj As System.Web.Mail.SmtpMail

'Variable to store the attachments
Dim Attachment As System.Web.Mail.MailAttachment

'Variable to create the message to send
Dim Mailmsg As New System.Web.Mail.MailMessage()
Double click on the "Add attachment" button to add the code. Type the following lines:

'Show open dialogue box to select the files to attach

Dim Counter As Integer
OFD.CheckFileExists = True
OFD.Title = "Select file(s) to attach"
OFD.ShowDialog()

For Counter = 0 To UBound(OFD.FileNames)
lstAttachment.Items.Add(OFD.FileNames(Counter))
Next
Double click on the "Remove attachment" button. Type the following lines:

'Remove the attachments
If lstAttachment.SelectedIndex > -1 Then
lstAttachment.Items.RemoveAt(lstAttachment.SelectedIndex)
End If
Double click on the "Send" button. Type the following lines:

Dim Counter As Integer

'Validate the data
If txtSMTPServer.Text = "" Then
MsgBox("Enter the SMTP server info ...!!!", _
MsgBoxStyle.Information, "Send Email")
Exit Sub
End If

If txtFrom.Text = "" Then
MsgBox("Enter the From email address ...!!!", _
MsgBoxStyle.Information, "Send Email")
Exit Sub
End If

If txtTo.Text = "" Then
MsgBox("Enter the Recipient email address ...!!!", _
MsgBoxStyle.Information, "Send Email")
Exit Sub
End If

If txtSubject.Text = "" Then
MsgBox("Enter the Email subject ...!!!", _
MsgBoxStyle.Information, "Send Email")
Exit Sub
End If

'Set the properties
'Assign the SMTP server
obj.SmtpServer = txtSMTPServer.Text

'Multiple recepients can be specified using ; as the delimeter
'Address of the recipient
Mailmsg.To = txtTo.Text

'Your From Address
'You can also use a custom header Reply-To for a different replyto address
Mailmsg.From = "\" & txtFromDisplayName.Text & "\ <" & txtFrom.Text & ">"

'Specify the body format
If chkFormat.Checked = True Then
Mailmsg.BodyFormat = MailFormat.Html 'Send the mail in HTML Format
Else
Mailmsg.BodyFormat = MailFormat.Text
End If

'If you want you can add a reply to header
'Mailmsg.Headers.Add("Reply-To", "Manoj@geinetech.net")
'custom headersare added like this
'Mailmsg.Headers.Add("Manoj", "TestHeader")

'Mail Subject
Mailmsg.Subject = txtSubject.Text

'Attach the files one by one
For Counter = 0 To lstAttachment.Items.Count - 1
Attachment = New MailAttachment(lstAttachment.Items(Counter))
'Add it to the mail message
Mailmsg.Attachments.Add(Attachment)
Next

'Mail Body
Mailmsg.Body = txtMessage.Text

'Call the send method to send the mail
obj.Send(Mailmsg)
techyashish
 
Posts: 10
Joined: Wed Oct 06, 2004 6:27 pm
Location: toronto

Thanks, but...

Postby cipango on Fri Oct 08, 2004 8:57 pm

...how about receiving email? That's what I need
cipango
 
Posts: 3
Joined: Fri Oct 08, 2004 8:27 pm

okey

Postby techyashish on Sat Oct 09, 2004 3:28 am

give me uar email


i will send you the program in the zip format

aki
techyashish
 
Posts: 10
Joined: Wed Oct 06, 2004 6:27 pm
Location: toronto

No no

Postby cipango on Sun Oct 10, 2004 2:27 am

what i was saying, I need a program that will only receive emails. Thanks anyway
cipango
 
Posts: 3
Joined: Fri Oct 08, 2004 8:27 pm


Who is online

Users browsing this forum: No registered users and 5 guests