' ------------------------------------------------------------------------------------ ' Send the selected picture by email ' ' This script uses the mapi setting to send the selected pictures of the ' current album by email. ' You must first define a 'my_profile' profile within Microsoft Exchange and configure it. ' ------------------------------------------------------------------------------------ Option Explicit app.ClearTrace dim alb, i, n, nbPic set alb = app.GetCurrentAlbum nbPic = alb.NbSelectedPicture app.trace nbPic & " pictures to send" Dim objSession, objMessage, objOneRecip, attachedObject ' create a session and log on -- username and password in profile Set objSession = CreateObject("MAPI.Session") ' change the parameters to valid values for your configuration objSession.Logon '"my_profile" ' create a message and fill in its properties Set objMessage = objSession.Outbox.Messages.Add objMessage.Subject = "Mailing pictures with MyAlbum" Dim sMsgText sMsgText = InputBox( "Enter the text of the mail", "MyAlbum mailer", "Here are the pictures...") objMessage.Text = sMsgText ' create the recipient 'Set objOneRecip = objMessage.Recipients.Add 'objOneRecip.Name = "Recipient Name" 'objOneRecip.Type = 1 'CdoTo 'objOneRecip.Resolve ' select the recipients in the adress book Set objMessage.Recipients = objSession.AddressBook( , "Select Attendees", TRUE, TRUE, 3 ) objMessage.Recipients.Resolve ' also updates everything 'MsgBox "Name of first recipient = " & objMessage.Recipient.Item(1).Name ' could be objRecipColl(1) since Item and Name are default properties ' Add the pictures as attached files n = alb.NbPicture dim pic, filename,k k = 1 for i = 0 to n-1 Set pic = alb.GetPicture(i) if pic.bSelected then ' Get the relative path of the picture filename = alb.ExpandMacro( pic, "%RP" ) app.Trace " Adding picture #" & i+1 & " " & filename set attachedObject = objMessage.Attachments.Add( , k, 1, filename ) attachedObject.Type = 1 'CdoFileData attachedObject.Source = filename attachedObject.ReadFromFile filename 'app.trace objMessage.Attachments.count k = k+1 end if next set attachedObject = objMessage.Attachments.Add ' get MAPI to determine complete e-mail address ' send the message and log off objMessage.Send app.trace "The message has been sent" objSession.Logoff