Changing the MailDefinition.BodyFileName of PasswordRecovery control programmatically?

Hi,

I have a passwordRecovery control and a custom text file which contains the Body of the email.  I get the email fine if I specify the File name at design time in the MailDefinition of the PasswordRecovery control:

 <MailDefinition From="info@Intamac.com" Subject="Your New Password" BodyFileName="PasswordMail.txt">  
    </MailDefinition>

However I need to set the Text file at runtime based on the users current theme.  I have tried to do this in the PasswordRecovery's sendingMail event but this just sends the default email out.  ie (doesn't apply the text file)  here's what i'm doing:

Protected Sub PswdRecovery_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles PswdRecovery.SendingMail
        Me.PswdRecovery.MailDefinition.BodyFileName = "PasswordMail.txt"
    End Sub

The text file is in the same dir as the page so this isn't the problem.  Any ideas?
fizzer666Asked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
Have you tried changing the BodyFileName before the SendingMail event?

Bob
0
 
fizzer666Author Commented:
I tried putting it in the page load event but only on a load eg:

If Not Page.IsPostBack Then
            Me.PswdRecovery.MailDefinition.BodyFileName = miscFunctions.getThemeDir & "/PasswordMail.txt"
  End If

This didn't work unless I take it out of the if condition.  At least now it works but this will fire multiple times.  Is there an event I can use which will only fire this once?
0
 
Bob LearnedCommented:
Is there a problem if the BodyFileName is set twice?

Bob
0
 
fizzer666Author Commented:
It doesn't effect the outcome but I just wondered whether there was a more efficient way.  In this instance, your right, I suppose it's not much of a perfomance hit.  Thanks for your help.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.