468,537 Members | 1,917 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

MAPI - attachment not working, and how to specify multiple recipients

hi....
i did this form for sending emails...
the form consists of:
text boxex:
from, to , subject , attachment...
buttons:
send , forward, ...etc


when i fill the info and send the email it will go , but i don't know how to use the attachment , i have the browse button near the attachment box so the user can choose which file to attach but when i send it the attachment will not appear in the inbox.
can someone help me with the coding....

this is my code:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Dim lPosition As Long
  4.  
  5.  
  6. Private Sub cmdBack_Click()
  7.  
  8.  
  9. If lPosition > 0 Then
  10.  
  11. lPosition = lPosition  1
  12.  
  13.  
  14.  
  15. MAPIMessages1.MsgIndex = lPosition
  16.  
  17. txtFrom.Text = MAPIMessages1.MsgOrigDisplayName
  18.  
  19. txtTo.Text = MAPIMessages1.RecipDisplayName
  20.  
  21. txtSubject.Text = MAPIMessages1.MsgSubject
  22.  
  23. txtMessage.Text = MAPIMessages1.MsgNoteText
  24.  
  25. 'txtAttach.Text = MAPIMessages1.Attachment
  26.  
  27.  
  28. End If
  29.  
  30. End Sub
  31.  
  32. Private Sub cmdBrowse_Click()
  33.  
  34.     Dim sFilenames()    As String
  35.     Dim i               As Integer
  36.  
  37.     On Local Error GoTo Err_Cancel
  38.  
  39.     With cmDialog
  40.         .FileName = ""
  41.         .CancelError = True
  42.         .Filter = "All Files (*.*)|*.*|HTML Files (*.htm;*.html;*.shtml)|*.htm;*.html;*.shtml|Images (*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif"
  43.         .FilterIndex = 1
  44.         .DialogTitle = "Select File Attachment(s)"
  45.         .MaxFileSize = &H7FFF
  46.         .Flags = &H4 Or &H800 Or &H40000 Or &H200 Or &H80000
  47.         .ShowOpen
  48.         ' get the selected name(s)
  49.         sFilenames = Split(.FileName, vbNullChar)
  50.     End With
  51.  
  52.     If UBound(sFilenames) = 0 Then
  53.         If txtAttach.Text = "" Then
  54.             txtAttach.Text = sFilenames(0)
  55.         Else
  56.             txtAttach.Text = txtAttach.Text & ";" & sFilenames(0)
  57.         End If
  58.     ElseIf UBound(sFilenames) > 0 Then
  59.         If Right$(sFilenames(0), 1) <> "\" Then sFilenames(0) = sFilenames(0) & "\"
  60.         For i = 1 To UBound(sFilenames)
  61.             If txtAttach.Text = "" Then
  62.                 txtAttach.Text = sFilenames(0) & sFilenames(i)
  63.             Else
  64.                 txtAttach.Text = txtAttach.Text & ";" & sFilenames(0) & sFilenames(i)
  65.             End If
  66.         Next
  67.     Else
  68.         Exit Sub
  69.     End If
  70.  
  71. Err_Cancel:
  72. End Sub
  73.  
  74. Private Sub cmdClose_Click()
  75. MAPISession1.SignOff
  76.  
  77. Unload Me
  78.  
  79.  
  80. End Sub
  81.  
  82. Private Sub cmdForward_Click()
  83.  
  84.  
  85. If lPosition < MAPIMessages1.MsgCount Then
  86.  
  87. lPosition = lPosition + 1
  88.  
  89.  
  90.  
  91. MAPIMessages1.MsgIndex = lPosition
  92.  
  93. txtFrom.Text = MAPIMessages1.MsgOrigDisplayName
  94.  
  95. txtTo.Text = MAPIMessages1.RecipDisplayName
  96.  
  97. txtSubject.Text = MAPIMessages1.MsgSubject
  98.  
  99. txtMessage.Text = MAPIMessages1.MsgNoteText
  100.  
  101.  
  102. End If
  103.  
  104. End Sub
  105.  
  106. Private Sub cmdSend_Click()
  107. 'Start by telling the control that we are composing an e-mail
  108.  
  109. MAPIMessages1.Compose
  110.  
  111.  
  112.  
  113. MAPIMessages1.RecipDisplayName = txtTo.Text
  114.  
  115. MAPIMessages1.MsgSubject = txtSubject.Text
  116.  
  117. MAPIMessages1.MsgNoteText = txtMessage.Text
  118. 'MAPIMessages1.Attachment = txtAttach.Text
  119.  
  120. MAPIMessages1.ResolveName
  121.  
  122.  
  123.  
  124. MAPIMessages1.Send
  125.  
  126.  
  127. End Sub
  128.  
  129. Private Sub Form_Load()
  130. 'Sign on to the MAPI Session
  131.  
  132. MAPISession1.SignOn
  133.  
  134. MAPIMessages1.SessionID = MAPISession1.SessionID
  135.  
  136. MAPIMessages1.Fetch
  137.  
  138.  
  139. End Sub
  140.  
  141.  
  142.  
one more thing please
if i want to send to more than one person how can i do this?
because it only sends to one person
thank you
Mar 2 '08 #1
0 981

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Bostjan | last post: by
3 posts views Thread by sentiboy | last post: by
1 post views Thread by bobh | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.