Visual Basic.NET - Sobre automatización aplicación.

 
Vista:
Imágen de perfil de jose
Val: 42
Ha aumentado su posición en 2 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Sobre automatización aplicación.

Publicado por jose (33 intervenciones) el 16/12/2013 18:48:45
Hola a todos,

Estoy realizando una aplicación que entre otras cosas envia correo electronicos en unas plantillas de html, plantillas cuyos contenidos es modificado por la aplicacion mediante placeholders [ejemplo].

Esto ya funciona, resulta que me piden que un grupo de personas pueda crear documentos a traves de la aplicación y utilizando las plantillas con el contenido que quieran. hasta no hay problema, se como hacerlo.

Lo dificil es que para que puedan mandar dichas plantillas a traves de la aplicación, he tenido que utilizar codigo. Ahora me piden que en el momento que se cree la nueva plantilla, esta pueda ser utilizada por todos sin tener que escribir codigo.

Mi pregunta es existe alguna forma de poder crear codigo apartir de codigo existente.

Este es el código que estoy utilizando para hacer esto:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
    'READ TEMPLATES TO BE SEND
    Private Sub readertemplate()
        Try
            myStreamReaderL1 = System.IO.File.OpenText(path)
            myStr = myStreamReaderL1.ReadToEnd()
            myStreamReaderL1.Close()
 
            Dim comment As String = CommentTMPTxt.Text + vbNewLine & vbNewLine
 
            myStr = myStr.Replace("[NAME]", UserTMPTxt.Text)
            myStr = myStr.Replace("[NUMINC1]", IncTMPTxt.Text)
            myStr = myStr.Replace("[NUMINC2]", IncTMPTxt.Text)
            If Not CommentTMPTxt.Text = "" Then
                myStr = myStr.Replace("[COMMENT]", comment)
            ElseIf CommentTMPTxt.Text = "" Then
                myStr = myStr.Replace("[COMMENT]", "")
            End If
            myStr = myStr.Replace("[ISSUE]", IssueTMPTxt.Text)
 
            If EmailTMPTxt.Text = "" Or IncTMPTxt.Text = "" Then
                MsgBox("Email addresss and Incident number is empty", MsgBoxStyle.Exclamation)
            ElseIf Not EmailTMPTxt.Text = "" Or IncTMPTxt.Text = "" Then
                item = olApp.CreateItem(Outlook.OlItemType.olMailItem)
                item.To = EmailTMPTxt.Text
                item.BodyFormat = OlBodyFormat.olFormatHTML
                item.HTMLBody = myStr
                'USING HAS A TEST
                item.SentOnBehalfOfName = "jose.rodriguez.an@gmail.com"
                'item.SentOnBehalfOfName = "trackin.sd@airbus.com"
                If LanguageCB.Text = "Spanish" Then
                    item.Subject = "CC1 - Numero de Incidencia " + IncTMPTxt.Text
                ElseIf LanguageCB.Text = "French" Then
                    item.Subject = "CC1 - numéro de l'incident " + IncTMPTxt.Text
                ElseIf LanguageCB.Text = "English" Then
                    item.Subject = "CC1 - Incident number " + IncTMPTxt.Text
                ElseIf LanguageCB.Text = "German" Then
                    item.Subject = "CC1 - Incident-Nummer " + IncTMPTxt.Text
                End If
 
                    item.Send()
                    MsgBox("Mail has been sent")
 
            End If
 
        Catch
            MsgBox("Template can't be found. Please contact a L2 Analyst", MsgBoxStyle.Critical, vbOKOnly)
        End Try
 
    End Sub
 
 
    'SEND TEMPLATES.
    Private Sub SendTMPBT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendTMPBT.Click
        Dim olAccounts As Outlook.Accounts
        olApp = New Outlook.Application()
        olSession = olApp.Session
        olAccounts = olSession.Accounts
 
        If LanguageCB.Text = "Language" Then
            MsgBox("Please choose the language and press sent", MsgBoxStyle.Information, vbOKOnly)
        ElseIf Not LanguageCB.Text = "Language" Then
 
 
 
            'CC1 SPANISH
            If tempCB.Text = "CC1 email" And LanguageCB.Text = "Spanish" Then
                'Holidays conditional.
                If WeendoffCK.Checked Then
                    'if it is holiday or weekend.
                    path = "c:\users\" + Environment.UserName + "\Dropbox\CalendarAssigneeTool\CalendarAssigneeTool\Resources\CC1SPANISHholidays.html"
                ElseIf Not WeendoffCK.Checked Then
                    'if it is not holiday or weekend.
                    path = "c:\users\" + Environment.UserName + "\Dropbox\CalendarAssigneeTool\CalendarAssigneeTool\Resources\CC1SPANISH.html"
                End If
 
                readertemplate()
End if

Agradeceria toda vuestra ayuda.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder