Re: Reply with attachment macro



Hi Eric,

I just got around to giving the macro a try. I'm bumping into this problem.
"The macros in this project are disabled. Please refer to the online help
or ducumentation of the host application to determine how to enable macros."

I've reduced macro security to low. self signed the macro, but continue to
get the same message. So if you know a quick solution that be great,
otherwise I'll post an update when I figure it out.

Thanks,
Matt



"Eric Legault [MVP - Outlook]" <elegaultZZZ@xxxxxxxxxxxxxxxxx> wrote in
message news:A14A6B85-846B-4149-B71F-93061353E751@xxxxxxxxxxxxxxxx
> Heh - I know I don't work for you because you don't pay me anything! :-)
> Anyway, it is not a problem - I love doing this stuff.
>
> Below is everything you need. This approach bypasses the need for an .oft
> file. All you need to change is the name of the attachment that is being
> auto-inserted into the reply, and the name of the signature as it appears
> in
> the Insert -> Signature menu.
>
> The first two procedures differ so that you map the first one to a toolbar
> in the Outlook window, and the other to a toolbar in an e-mail window.
>
> Rock and roll!
>
> Option Explicit
> Public Declare Function GetUserName Lib "advapi32.dll" Alias
> "GetUserNameA" _
> (ByVal lpBuffer As String, nSize As Long) As Long
>
> Sub ReplyWithTemplateFromOutlook()
> If ActiveExplorer.Selection.Count = 0 Or ActiveExplorer.Selection.Count
>> 1 Then
> 'No selected e-mail message to respond to, or too many selected -
> should only select one
> Exit Sub
> End If
>
> If ActiveExplorer.Selection.Item(1).Class <> olMail Then
> 'Only reply to e-mail items
> Exit Sub
> End If
>
> ReplyToCurrentMessage ActiveExplorer.Selection.Item(1)
> End Sub
>
>
> Sub ReplyWithTemplateFromEmail()
>
> If ActiveInspector Is Nothing Then
> 'No open e-mail message to respond to!
> Exit Sub
> End If
>
> If ActiveInspector.CurrentItem.Class <> olMail Then
> 'Only reply to e-mail items
> Exit Sub
> End If
>
> ReplyToCurrentMessage ActiveInspector.CurrentItem
> End Sub
>
> Private Sub ReplyToCurrentMessage(MessageToReply As Outlook.MailItem)
> Dim objReply As Outlook.MailItem
> Dim strSignatureText As String
>
> Set objReply = MessageToReply.Reply
>
> 'Insert a particular signature by calling function with the name of the
> signature from the Insert -> Signature menu
> strSignatureText = GetSignatureTextByName("webadmin")
>
> 'Insert signature at the beginning of reply body text
> 'If signatures are already automatically inserted, this will insert a
> second signature!!! no way around this
> objReply.Body = strSignatureText & vbCrLf & objReply.Body
>
> 'Auto insert the file you want attached
> objReply.Attachments.Add "C:\Temp\test.txt", OlAttachmentType.olByValue
> objReply.Display
> Set objReply = Nothing
> End Sub
>
> Function GetSignatureTextByName(SignatureName As String) As String
>
> Dim objFS As New Scripting.FileSystemObject, objTS As
> Scripting.TextStream
> Dim objF As Scripting.Folder, strSysDrive As String
> Dim strUserName As String
> Dim strExtension As String
>
> Set objF = objFS.GetSpecialFolder(0)
> strSysDrive = Left(objF, 1)
> strUserName = FindUserName
> Set objTS = objFS.OpenTextFile(strSysDrive & ":\Documents and
> Settings\"
> & strUserName & "\Application Data\Microsoft\Signatures\" & SignatureName
> _
> & ".txt", ForReading, False, TristateFalse)
> If objTS Is Nothing Then Exit Function
> GetSignatureTextByName = objTS.ReadAll
> objTS.Close
> Set objTS = Nothing
> Set objFS = Nothing
> Set objF = Nothing
> End Function
>
> Public Function FindUserName() As String
>
> Dim strBuffer As String
> Dim lngSize As Long
>
> strBuffer = String(100, " ")
> lngSize = Len(strBuffer)
>
> If GetUserName(strBuffer, lngSize) = 1 Then
> FindUserName = Left(strBuffer, lngSize)
> Else
> Exit Function
> End If
>
> 'ELIMINATES NULL CHARACTERS
> FindUserName = Replace(FindUserName, Chr(0), "")
> End Function
>
> --
> Eric Legault - B.A, MCP, MCSD, Outlook MVP
> Try Picture Attachments Wizard for Outlook! http://tinyurl.com/ckytm
> Job: http://www.imaginets.com
> Blog: http://blogs.officezealot.com/legault/
>
>
> "Matt" wrote:
>
>> Hi Eric,
>>
>> 2 other things I just noticed. It would be nice for the macro to work
>> from
>> the main OLK window rather than having to actually open the message. The
>> other is that because it's not a reply it doesn't include the senders
>> message. You already know that, I just realized. So it seams as though
>> the
>> alternative method will end up being more appropriate.
>>
>> I realize you don't work for me. If you were able to pop that out
>> quickly
>> that would be great. If not I hope you have a great day because you've
>> already done me a great deed.
>>
>> Thanks again,
>> Matt
>>
>>
>>
>> "Eric Legault [MVP - Outlook]" <elegaultZZZ@xxxxxxxxxxxxxxxxx> wrote in
>> message news:24D61E20-82D7-496E-B6C9-E59C92B332C6@xxxxxxxxxxxxxxxx
>> > The macro below will do something close to what you want. Note though
>> > that
>> > this isn't a "true" reply - the original message text is not handled as
>> > per
>> > Outlook's message reply settings. You'll have to code that stuff
>> > yourself,
>> > as you cannot reply with a template as you would create an e-mail from
>> > a
>> > template.
>> >
>> > For more resources on coding macros, see:
>> >
>> > Visual Basic and VBA Coding in Microsoft Outlook:
>> > http://www.outlookcode.com/d/vb.htm
>> >
>> > Sub ReplyWithTemplate()
>> > Dim objReply As Outlook.MailItem
>> > Dim objMsg As Outlook.MailItem
>> >
>> > If ActiveInspector Is Nothing Then
>> > 'No open e-mail message to respond to!
>> > Exit Sub
>> > End If
>> >
>> > If ActiveInspector.CurrentItem.Class <> olMail Then
>> > 'Only reply to e-mail items
>> > Exit Sub
>> > End If
>> >
>> > Set objMsg = ActiveInspector.CurrentItem
>> > Set objReply = Application.CreateItemFromTemplate("C:\Documents and
>> > Settings\webadmin\Desktop\Test.oft")
>> >
>> > objReply.To = objMsg.SenderEmailAddress
>> > objReply.Subject = "RE: " & objMsg.Subject
>> > objReply.Display
>> >
>> > Set objReply = Nothing
>> > Set objMsg = Nothing
>> > End Sub
>> >
>> > --
>> > Eric Legault - B.A, MCP, MCSD, Outlook MVP
>> > Try Picture Attachments Wizard for Outlook! http://tinyurl.com/ckytm
>> > Job: http://www.imaginets.com
>> > Blog: http://blogs.officezealot.com/legault/
>> >
>> >
>> > "Matt" wrote:
>> >
>> >> hello,
>> >>
>> >> I would like a one click button that replies to a message with a
>> >> template
>> >> that includes an attachment. It seems that a macro will be necessary,
>> >> but I
>> >> don't know how to build the code. Alternatively the reply macro could
>> >> insert a particular signature and attach a particular file rather than
>> >> use a
>> >> template.
>> >>
>> >> I tried creating a rule that sends a template to messges in a cetain
>> >> category, but changing the category of the message after it's recieved
>> >> seems
>> >> to make the rule unreliable.
>> >>
>> >> Any suggestions would be great, including those on how to get started
>> >> writing macros for myself.
>> >>
>> >> Thanks in advance,
>> >> Matt
>> >>
>> >>
>> >>
>>
>>
>>


.


Loading