Advertisement

02.15.2007 at 10:21AM PST, ID: 22392089
[x]
Attachment Details

Using a UNC path in an internal email

Asked by omegamueller in .NET Framework 2.0, Microsoft Visual Basic.Net

Tags: unc, path, email

I am a newbie with vb.net and cannot find a solution.  I am trying to send an internal email whenever a new file is created in a subfolder.  I can successfully monitor and send an email, but can't figure out how to include a UNC path that user can simply click on to open the newly created file.  I am open to using SMTP or HTML to make this happen.  The line I am struggling with is the “mail.Body = “ line.

Imports System.IO
Imports System.Diagnostics
Imports System.Net.Mail

Public Class Form1
    Public watchfolder As FileSystemWatcher ' public variable
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_start.Click
        watchfolder = New System.IO.FileSystemWatcher()
        watchfolder.Path = "c:\scanfolders"    ' path to monitor
        watchfolder.Filter = "*.pdf"
        watchfolder.IncludeSubdirectories = True

        'add filter to montor for filename
        watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName

        ' add the handler to for the event  
        AddHandler watchfolder.Created, AddressOf logchange
        watchfolder.EnableRaisingEvents = True
    End Sub

    Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
        Dim EmailAddress, PDFpath, PDFname As String
        Dim mail As New MailMessage()

        PDFpath = e.Name
        txt_folderactivity.Text &= "PDFpath: " & PDFpath & vbCrLf
        EmailAddress = Microsoft.VisualBasic.Left(PDFpath, ((InStr(PDFpath, "\")) - 1)) & "@mycompany.com"
        PDFname = Mid(PDFpath, (InStr(PDFpath, "\") + 1), (Len(PDFpath) - (InStr(PDFpath, "\"))))

        '********** Send email as SMTP
        'set the addresses
        mail.From = New MailAddress("ScanMonitor@mycompany.com")
        mail.To.Add(EmailAddress)
        'set the content
        mail.Subject = "You have a new scanned file"
        mail.Body = "Click the link to view your document: \\wbprint\" & PDFpath
        'send the message
        Dim smtp As New SmtpClient("mail.mycompany.com")
        smtp.Send(mail)
        '***********************************************************************
    End Sub
End ClassStart Free Trial
[+][-]02.15.2007 at 10:25AM PST, ID: 18542601

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, Microsoft Visual Basic.Net
Tags: unc, path, email
Sign Up Now!
Solution Provided By: sirbounty
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32