Home > Software engineering >  Please modify the code
Please modify the code

Time:09-22

This code is to realize online automatic outlook 2010 reply with attachments, but this code the pictures in the email body, also automatically bring to the attachment!

Now a great god, please help to modify the code to reply email with an attachment in the attachment, only when no pictures of the body is also automatically into the attachment as the attachment, thanks!

The code is as follows:
 Sub ReplyWithAttachments () 
Dim RPL As Outlook. MailItem
Dim itm As Object

The Set itm=GetCurrentItem ()
If Not itm Is Nothing Then
The Set of RPL=itm. Reply
CopyAttachments itm, RPL
RPL. Display
End the If

The Set of RPL=Nothing
The Set of itm=Nothing
End Sub
As the Object Function GetCurrentItem ()
Dim objApp As Outlook. Application

The Set objApp=Application
On the Error Resume Next
The Select Case TypeName (objApp. ActiveWindow)
Case "Explorer"
The Set GetCurrentItem=objApp. ActiveExplorer. Selection. The Item (1)
Case "Inspector"
The Set GetCurrentItem=objApp. ActiveInspector. CurrentItem
End the Select

The Set objApp=Nothing
End the Function
Sub CopyAttachments (objSourceItem objTargetItem)
The Set of fso=CreateObject (" Scripting. FileSystemObject ")
The Set fldTemp=fso. GetSpecialFolder (2) 'TemporaryFolder
StrPath=fldTemp. Path & amp; ""
For Each objAtt In objSourceItem. Attachments
StrFile=strPath & amp; ObjAtt. FileName
ObjAtt. SaveAsFile strFile
ObjTargetItem. Attachments. The Add strFile,,, objAtt. DisplayName
Fso. DeleteFile strFile
Next
The Set fldTemp=Nothing
The Set of fso=Nothing
End Sub
Sub ReplyToAllWithAttachments ()
Dim RPL As Outlook. MailItem
Dim itm As Object

The Set itm=GetCurrentItem ()
If Not itm Is Nothing Then
The Set of RPL=itm. ReplyAll
CopyAttachments itm, RPL
RPL. Display
End the If

The Set of RPL=Nothing
The Set of itm=Nothing
End Sub
  • Related