Link to home
Start Free TrialLog in
Avatar of fizzer666
fizzer666

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fizzer666
fizzer666

ASKER

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?
Is there a problem if the BodyFileName is set twice?

Bob
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.