Link to home
Start Free TrialLog in
Avatar of noodleNT
noodleNT

asked on

Custom Form Autogen VB email - Insert a Picture to the body?

I have a custom for that sends out email alerts when tasks are marked complete. The email alerts are generated in the VB script of the form. I was wondering if there is a way to insert our corporate logo into the email some where?

Here is another thought - Just jumped the point value

Is it possible to wright some HTML code in a text box. Then use that to create an HTML body email. The text box containing the HTML code would also have to grab values stored in the form. These HTML source code text boxes could be saved on a hidden tab or something.
Avatar of stefri
stefri
Flag of France image

Have your custom form create a mail based on a template you have saved to Org Lib as hidden item
The script can also replace part of the orglib html body using specific coding such as
$contact$ etc
It is just a question of getting the orglib.HTMLBody then use various replace to loop through your $tags$

The orglib template will also have the Compay logo.

I usually design the OL html body with FrontPage, add images, tables etc then use File/Send
Instead of sending, I save to Drafts, images are mime encoded
Then reopen from Drafts and publish to Orglib

Add method as it applies to the Items object.

Creates a new Outlook item in the Items collection for the folder, and returns the new item. If not specified, the Type of the item defaults to the type of the folder, or to MailItem if the parent folder is not typed.

expression.Add(Type)

expression     Required. An expression that returns an Items collection object.

Type   Optional. Variant. The Outlook item type for the new item. Can be one of the following OlItemType constants: olAppointmentItem, olContactItem, olJournalItem, olMailItem, olNoteItem, olPostItem, or olTaskItem, one of the following OlOfficeDocItemsType constants: olExcelWorkSheetItem, olPowerPointShowItem, or olWordDocumentItem, or any valid message class. Specify the MessageClass to create custom forms.
The MessagClass is the name you give to your form when publishing

Stefri
Avatar of noodleNT
noodleNT

ASKER

orglib is the Organizational Forms Library?
Also do the bodying coding variables have to be the same as the the variable defined in the form? If so can spaces be in theses variables? $No_Spaces$ or $No Spaces$
Will this be the correct way to format the body?

They will be working for the $Department$ Department out of the $Office$ office. Their position is $Position$.
Alright... I think I am ready to parse out the variables with what is stored from the form..... I am not quite sure how to do that part. BTW.. I didn't relize how involved this was going to be so I increased the point value another 50.
Ok... now I am confused.

To use the template do I use the createitemfromtemplate command? If so how do I tell it to use whats in the Orginizational Form Library?
ASKER CERTIFIED SOLUTION
Avatar of stefri
stefri
Flag of France 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
Should the Template just bee the message body or have the full email send template? (with TO and From fields and what not)

Also... I cant seem to figure out how to Hide the template in the OFL.

Thanks man! This is going to kick butt! :)
The template is what you want to send. To field may be pre-adressed. From is set at run time using your default mailbox name. The message body is just your standard text with your tags $So ans So$

When you publish, go to Properties Tab and click Use form for responses only; this is not mandatory but it avoid users to pickup designed forms.

Stefri
This blew my boss away!!!

THANKS!!!
Do we share the raise? ;-)
Stefri
HEHE.... No raise yet but he keeps thinking about moving me over from support to the development team. ;)

Quick question on the replace function.

I need to insert multiple lines for one veriable. When I do so I get "False" as the result. Since this is HTML do I switch the chr(13) with <br> to get this to work?

Also... Just a note. In another thread I was asking about creating a hyperlink within a VBscript autogenerated email. Well.. you can do it if you use the template. Create the text you want displayed in the template. Then use the create hyperlink option. Instead of putting in the long URL location just put in your variable, say $URL$, you can then replace that in the code using the steps above with the URL you want.  I did this with a simple mailto link which works perfectly. Turns out all my questions are getting solved with your answere here!
chr(13) with <br> to get this to work? Yes. It may happen yhay you have chr(10) insraed of chr(13)

The last thread was adding a URL to a Public Folder: it will still not work using <outlook://.....>
The HTML, in Outlook, is decoded by IE engine.

Stefri
It does work for the link. Get rid of the < > and it works fine.
No kidding, I will try tomorrow at office. Does it handle the extra spaces in Publi Folders/All Public Folders

Stefri
yeah.. it automatically puts the space filler in the URL. I am going to test right now if I can open the item directly instead of going to the folder. I will let you know of the results.
I tested it, not wotking
I set the bodyformat to HTML. Here is my code to generate the email:


      Set AlertFolder = g_oNS.GetDefaultFolder(6) 'olFolderInbox
      Set AlertMessage1 = AlertFolder.Items.Add("IPM.Note.Templates - New Employee Setup Request")
      Set AlertMessage2 = AlertFolder.Items.Add("IPM.Note.Templates - New Employee Setup Request")

      'Body Format
      bfNumber = 2

      HERE1 = "outlook://public folders/all public folders/G. Information Technology/" & _
              "1. ACAS Internal Communications/a. Account Requests - Submitted"

                  If Alert_Disabled = False Then
                        If Alert_Test = True Then
                              MsgBox "Messages Redirected for Testing." , , "TESTING FORM"
                              Email1 = Requester
                        Else
                              Email1 = "ACAS - Human Resources"
                        End If
                        AlertMessage1.To = Email1                        
                        AlertMessage1.Subject = "Pending Account Approval: " & AlertSubject
                        AlertMessage1.FlagStatus = 2
                        AlertMessage1.FlagDueBy = Due
                        AlertMessage1.bodyformat = bfNumber

                        htmBody = AlertMessage1.HTMLbody
                        FullName = FirstName & " " & LastName
                        ItemStatus = "Pending request approval from HR Department"
                        PublicFolder = "This request can be found at Public Folders G.\1.\a."
                        PFLink = HERE1

                        tmpBody = Replace(htmBody,"$Subject$", msgSubject,1)
                        tmpBody = Replace(tmpBody,"$Employee_Name$", FullName,1)
                        tmpBody = Replace(tmpBody,"$Employee_StartDate$", StartDate,1)
                        tmpBody = Replace(tmpBody,"$Hiring_Manager$", HiringManager,1)
                        tmpBody = Replace(tmpBody,"$ItemStatus$", ItemStatus,1)
                        tmpBody = Replace(tmpBody,"$Department$", Department,1)
                        tmpBody = Replace(tmpBody,"$Office$", Office,1)
                        tmpBody = Replace(tmpBody,"$Position$", Position,1)
                        tmpBody = Replace(tmpBody,"$Requester$", Requester,1)
                        tmpBody = Replace(tmpBody,"$PublicFolder$", PublicFolder,1)
                        tmpBody = Replace(tmpBody,"$PFLink$", PFLink,1)

                        AlertMessage1.HTMLbody = tmpBody
                        AlertMessage1.Send
                        MsgBox "The new account information has been sent to HR for approval." , , "Email Sent"
                  End If


Then in the template I created the HERE text then used the create Hyperlink but for the URL i used $PFLinks$.

If you still have problems I can send you the template.
BTW... I havent figured out how to open the Item directly yet. I thought I could use the URL and then add Subject.EML but it didnt work.
in a plaint text message or RTF, accessing the item is <outlook://path to folder/~subject>
stefri
So I want to use:
<outlook://path to folder/~subject>

Not:
<outlook://path to folder/subject.EML>

to  open the item directly? Why the "~" ?

Have you had any luck yet with the URL in the template?