Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot get IIS pickup directory

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
Hi

I am getting this error messsage when I submit a form on my website. the code behind the button is:

Code:
Imports Microsoft.VisualBasic
Imports System.net.Mail

Public Class SendEmail
    Public Sub SendEmailMessage(ByVal strFrom As String, ByVal strTo() _
    As String, ByVal strSubject _
    As String, ByVal strMessage _
    As String, ByVal fileList() As String)
        'This procedure takes string array parameters for multiple recipients and files
        Try
            For Each item As String In strTo
                'For each to address create a mail message
                Dim MailMsg As New System.Net.Mail.MailMessage
                'Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(item))
                'MailMsg.BodyEncoding = Encoding.Default
                MailMsg.Subject = strSubject.Trim()
                MailMsg.Body = strMessage.Trim() & vbCrLf
                MailMsg.Priority = MailPriority.High
                MailMsg.IsBodyHtml = True

                'attach each file attachment
                For Each strfile As String In fileList
                    If Not strfile = "" Then
                        Dim MsgAttach As New Attachment(strfile)
                        MailMsg.Attachments.Add(MsgAttach)
                    End If
                Next

                'Smtpclient to send the mail message
                Dim smtpMail = New SmtpClient("212.227.101.65")
                'Dim SmtpMail As New System.Net.Mail.SmtpClient
                'SmtpMail.Credentials = New System.Net.NetworkCredential("mailsend", "mailsend")
                'SmtpMail.Host = "127.0.0.1"
                smtpMail.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
                SmtpMail.Send(MailMsg)
            Next
            'Message Successful
        Catch ex As Exception
            'Message Error
        End Try
    End Sub

    Public Sub SendEmailMessage(ByVal strFrom As String, ByVal strTo _
    As String, ByVal strSubject _
    As String, ByVal strMessage _
    As String, ByVal file As String)
        'This procedure overrides the first procedure and accepts a single
        'string for the recipient and file attachement 
        Try
            Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
            MailMsg.BodyEncoding = Encoding.Default
            MailMsg.Subject = strSubject.Trim()
            MailMsg.Body = strMessage.Trim() & vbCrLf
            MailMsg.Priority = MailPriority.High
            MailMsg.IsBodyHtml = True

            If Not file = "" Then
                Dim MsgAttach As New Attachment(file)
                MailMsg.Attachments.Add(MsgAttach)
            End If

            'Smtpclient to send the mail message
            Dim SmtpMail As New SmtpClient
            SmtpMail.Host = "88.208.195.75"
            SmtpMail.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
            SmtpMail.Send(MailMsg)
        Catch ex As Exception
            'Message Error
        End Try
    End Sub
End Class

Any ideas what could be wrong with the code
 
Sorry this is my code

Code:
Imports System.Net.mail
Imports Microsoft.VisualBasic

Public Class Email_SMS

    Public Sub send_email(ByVal emailTo As String, ByVal emailFrom As String, ByVal emailSubject As String, ByVal emailBody As String)

        Dim mail As New MailMessage()

        'set the addresses
        mail.To.Add(emailTo)
        mail.From = New MailAddress(emailFrom)
        mail.IsBodyHtml = True


        'set the content
        mail.Subject = (emailSubject)
        mail.Body = (emailBody)

        'send the message
        Dim smtp As New SmtpClient("87.106.106.242")
        smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
        smtp.Send(mail)

    End Sub

    Public Sub email_attach(ByVal emailTo As String, ByVal emailCC As String, ByVal emailBCC As String, ByVal emailFrom As String, ByVal emailSubject As String, ByVal emailBody As String, ByVal newattach As String)

        Dim mail As New MailMessage()

        'set the addresses
        mail.To.Add(emailTo)
        mail.CC.Add(emailCC)
        mail.Bcc.Add(emailBCC)
        mail.From = New MailAddress(emailFrom)
        mail.IsBodyHtml = True

        Dim attachFile As New Attachment(newattach)

        mail.Attachments.Add(attachFile)

        'set the content
        mail.Subject = (emailSubject)
        mail.Body = (emailBody)

        'send the message
        Dim smtp As New SmtpClient("87.106.106.242")
        smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
        smtp.Send(mail)
    End Sub

    Public Sub email_attach2(ByVal emailTo As String, ByVal emailBCC As String, ByVal emailFrom As String, ByVal emailSubject As String, ByVal emailBody As String, ByVal attach1 As String, ByVal attach2 As String)

        Dim mail As New MailMessage()

        'set the addresses
        mail.To.Add(emailTo)
        mail.Bcc.Add(emailBCC)
        mail.From = New MailAddress(emailFrom)
        mail.IsBodyHtml = True

        Dim attachFile1 As New Attachment(attach1)
        Dim attachFile2 As New Attachment(attach2)

        mail.Attachments.Add(attachFile1)
        mail.Attachments.Add(attachFile2)

        'set the content
        mail.Subject = (emailSubject)
        mail.Body = (emailBody)

        'send the message
        Dim smtp As New SmtpClient("87.106.106.242")
        smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
        smtp.Send(mail)
    End Sub

End Class
 
Here is the error:

Code:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Cannot get IIS pickup directory.

Source Error:

Line 37:         Dim emailSubject As String = "Thank you for contacting Andrew Prior - Primagic Solutions Ltd"
Line 38: 
Line 39:         SendEmail.send_email(emailTo, emailFrom, emailSubject, emailbody)
Line 40: 
Line 41:         ' Send Lead E-Mail


Source File: C:\Inetpub\vhosts\primagic.co.uk\httpdocs\contact.aspx.vb    Line: 39

Stack Trace:

[SmtpException: Cannot get IIS pickup directory.]
   System.Net.Mail.IisPickupDirectory.GetPickupDirectory() +1101325
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1480
   Email_SMS.send_email(String emailTo, String emailFrom, String emailSubject, String emailBody) +139
   _Contact.send_email() in C:\Inetpub\vhosts\primagic.co.uk\httpdocs\contact.aspx.vb:39
   _Contact.cmd_Send_Click(Object sender, EventArgs e) in C:\Inetpub\vhosts\primagic.co.uk\httpdocs\contact.aspx.vb:12
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
 
YOu'll have to debug your code and trace int the SendEmail.Send_email sub.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top