• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

I send a attachment in mail on VB and user receives without extension of file.

My problem is that I send a mail within attachment (example: file.doc), the user receives this mail with file but this file without it extension, only "file". The user doesnt knows what type is this file, if is a Word file or a Excel file or other file.

The code of Vb mail:
Me.MAPIMessages1.AttachmentIndex = Me.MAPIMessages1.AttachmentCount

Me.MAPIMessages1.AttachmentType = 0

Me.MAPIMessages1.AttachmentPosition = Me.MAPIMessages1.AttachmentIndex

Me.MAPIMessages1.AttachmentPathName = "c:\sendmail\pedido.doc"

Me.MAPIMessages1.AttachmentName = "Pedido.Doc"


1 Solution
Hi ogir,

Private Sub Command1_Click()
    ' this command button is used to start a MAPI session, log on the
    '     the
    ' mail service, attach the created check summary text file to a n
    '     ew
    ' message, send the message and then close the session
    ' declare local variables here
    Dim strUserId As String
    Dim strPassword As String
    Dim strFileName As String
    Dim strFilePath As String
    ' set the mouse pointer to indicate the app is busy
    Screen.MousePointer = vbHourglass
    ' set the values for the file name and the file path
    strFileName = "sendmail.frm" ' this is where you would put any file attachments
    strFilePath = App.Path & "\"
    ' set the user name and password properties on the session contro
    '     l
    mapiLogOn.UserName = "user" ' network user name and password !
    mapiLogOn.Password = "testing"
    ' start a new email session

    Do While mapiLogOn.SessionID = 0

        DoEvents ' need to wait until the new session is created

        'create a new message and address it
        MAPIMessages1.SessionID = mapiLogOn.SessionID
        MAPIMessages1.RecipDisplayName = "Danny Setiawan"
        MAPIMessages1.AddressResolveUI = True
        MAPIMessages1.RecipAddress = "smtp:ashiang@hotmail.com"
        ' note that I prefixed the address with "smtp". This is required
        '     by exchange
        ' server, or it does not know what service to use for outgoing ma
        '     il.
        MAPIMessages1.MsgSubject = "Test of the Email function"
        MAPIMessages1.MsgNoteText = " This is a test of the email function, If you" _
        & "receive this Then the program has worked successfully." & vbCrLf
        ' attaching the file
        MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) - 1
        ' the line above places the attachment at the end of the text.
        MAPIMessages1.AttachmentPathName = strFilePath & strFileName
        ' now send the message
        MAPIMessages1.Send False
        MsgBox "File sent to specified receiptent."
        ' now set the mouse pointer back to normal
        Screen.MousePointer = vbNormal
End Sub

note : mapiLogOn is same as MAPISession1 ( rename   MAPISession1 to mapiLogOn

try this

            Me.MAPIMessages1.AttachmentName = ""
            ' position must be at the end of the message body - 1, read the help file
            Me.MAPIMessages1.AttachmentPosition = Len(Me.MAPIMessages1.MsgNoteText) - 1

Me.MAPIMessages1.AttachmentPathName = "c:\sendmail\pedido.doc"

'get rid of this
'Me.MAPIMessages1.AttachmentName = "Pedido.Doc"
ogirAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now