×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MAPI to select mail recipient

MAPI to select mail recipient

MAPI to select mail recipient

(OP)
The following code (less MAPI) Which I added in a different forum will send email to name in address line.  What I want to do is have the new mail window without an address so you can add your own.

CODE

Function SendIt(sRecip As String, sTitle As String, sText As String, sFile As String) As Boolean
Dim strTemp      As String
 Dim strError      As String
 Dim lngIndex      As Long
 Dim iFileCount As Integer
     
 Dim mRecip(0) As MapiRecip, mFile() As MapiFile, mMail As MAPIMessage
 Dim lSess As Long, lRet As Long
 

 On Error GoTo ErrorHandler
 SendIt = False
     
 'Add 2 trailing spaces to the text, this will be the position where the attachment goes to
 sText = sText & "  "
     
 'Recipient
 With mRecip(0)
      .Name = sRecip
      .RecipClass = MAPI_TO
   End With
     
    'File to send?
   If sFile <> "" Then
      ReDim mFile(0)
      With mFile(0)
      .FileName = sFile
      .PathName = sFile
      .Position = Len(sText) - 1
      .FileType = ""
      .Reserved = 0
   End With
      iFileCount = 1
   End If
     
    'Create Mail
   With mMail
      .Subject = sTitle
      .NoteText = sText
      .Flags = 0
      .FileCount = iFileCount
      .RecipCount = 1
      .Reserved = 0
      .DateReceived = ""
      .MessageType = ""
   End With
     
   'Post it
   'Logon: User = "" and Password = ""
  lRet = MAPILogon(0, "", "", MAPI_LOGON_UI, 0, lSess)
   If lRet <> SUCCESS_SUCCESS Then
       strError = "Error logging into messaging software. (" & CStr(lRet) & ")"
        GoTo ErrorHandler
   End If
     
    'Send the mail to the given recipients with the attached file without showing a dialog
   lRet = MAPISendMail(lSess, 0, mMail, mRecip, mFile, MAPI_NODIALOG, 0)
   If lRet <> SUCCESS_SUCCESS And lRet <> MAPI_USER_ABORT Then
        If lRet = 14 Then
            strError = "Recipient not found"
        Else
           strError = "Error sending: " & CStr(lRet)
        End If
        GoTo ErrorHandler
    End If
     
    lRet = MAPILogoff(lSess, 0, 0, 0)
     
   SendIt = True
    Exit Function
     
ErrorHandler:
    If strError = "" Then strError = Err.Description
    Call MsgBox(strError, vbExclamation, "MAPI-Error")
End Function

Sub Autoclose()
 

    Dim strDocName As String
    Dim intPos As Integer


      intPos = InStrRev(strDocName, ".")
        
strDocName = ActiveDocument.FullName
     
        SendIt "me@mysite.com", "A new Access Card for person below", "Hi, read this:", strDocName
    Application.ScreenUpdating = True
   End Sub

Never give up never give in.

There are no short cuts to anything worth doing   smile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close