Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   attachment method issue (http://www.go4expert.com/forums/attachment-method-issue-t25836/)

firoz.raj 19May2011 18:23

attachment method issue
 
hi friends. i have been trying to send excel sales file on email as attachment .but log file is comming as a attachment but excel file is not comming as a attachment .can you see the look? .Kindly let me know please .
Code:

  Public Sub SendMail(ByVal Attachmentfile As String)
        Dim strMsg$
        Dim filenumber%
        Dim tmpfilename$
        On Error GoTo errhnd
        Set poSendMail = New vbSendMail.clsSendMail
        poSendMail.SMTPHost = "mail.alhokair.com.sa"
    '  poSendMail.SMTPHost = "smtp.gmail.com"
        poSendMail.AsHTML = True
        poSendMail.From = "application.support@alhokair.com.sa"
        poSendMail.FromDisplayName = "Application Support"
        poSendMail.RecipientDisplayName = "firoz.mallik"
        poSendMail.Recipient = "firoz.mallik@alhokair.com.sa"
    '  poSendMail.Recipient = "firoz.raj@gmail.com"
    '  poSendMail.CcRecipient = "firoz.mallik@alhokair.com.sa"
        poSendMail.Subject = "CNK Sales summary _ China"
        poSendMail.Message = "<html>" & vbCrLf & _
                    " <head> " & vbCrLf & _
                    "<title>Inditex Automated</title> " & vbCrLf & _
                    " </head> " & vbCrLf & _
                    " <body> " & vbCrLf & _
                    strMsg & vbCrLf & _
                    " </body> " & vbCrLf & _
                    " </html>"
        poSendMail.Attachment = Attachmentfile
        poSendMail.Send
        Set poSendMail = Nothing
        Exit Sub
errhnd:
        If Err.Number <> 0 Then
            logfilename = "C:\CNK\" & Format$(Now, "DDMMYYYY") & ".txt"
            filenumber = FreeFile()
            Open logfilename For Append As #filenumber
            Print #filenumber, Err.Number, Err.Description, Now()
          ' Print #filenumber, Err.Description
            Close #filenumber
    End If
    End Sub

Public Function CreateExcelSheet(ByRef rssales As ADODB.Recordset, path As String) As String
          Dim i%
          Dim filename$
          i = 0
            For Each adofields In rssales.Fields
                osheet.Range("A1").Offset(0, i).Value = UCase(adofields.Name)
                i = i + 1
            Next
            osheet.Range("A2").CopyFromRecordset rssales
            osheet.Columns("H").Delete
            osheet.Columns("A").Delete
            objexcel.Application.DisplayAlerts = False
            If Dir("C:\cnk", vbDirectory) = "" Then
                MkDir "C:\CNK"
            End If
            filename = "C:\CNK\" & Format$(Date, "DDMMYYYY") & ".xls"
            wbook.SaveAs path
            wbook.Close
            objexcel.Application.DisplayAlerts = False
            objexcel.Quit
            CreateExcelSheet = filename
            Call SendMail(filename)
            End Function

:D


All times are GMT +5.5. The time now is 08:04.