Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change to Macro Outlook 2007

Posted on 2010-11-29
3
Medium Priority
?
166 Views
Last Modified: 2012-05-10
Hi all,

I have a macro for creating a new email and I would like to make a change to it so that it includes an image in it. I have attached a sample artwork of the way I would like it to look.  Any advice on how to add this would be greatly appreciated.

Best regards,

Derek
Sub editten(mai As Variant)
Dim para As Variant
Dim strArray() As String
Dim nuMai As Object
Dim strSearchFor() As Variant: strSearchFor = Array("Email:", "Shipping Company:", "Tracking Number:", "Estimated Arrival Date:", "Contact:", "Company Name:")
Dim strResults() As String
Dim elem As Integer
Const str2 As String = ""
Const str3 As String = ""
Const str4 As String = ""
    
    ReDim strResults(UBound(strSearchFor))
'    If TypeName(Application.ActiveWindow) = "Explorer" Then
'        Set mai = Application.ActiveExplorer.Selection.item(1)
'    ElseIf TypeName(Application.ActiveWindow) = "Inspector" Then
'            Set mai = Application.ActiveInspector.CurrentItem
'    Else
'        Exit Sub
'    End If
    With mai
        strArray = Split(.Body, vbCrLf)
        For Each para In strArray
            If para <> "" Then
                For elem = LBound(strSearchFor) To UBound(strSearchFor)
                    If LCase(Left(para, Len(strSearchFor(elem)))) = LCase(strSearchFor(elem)) Then strResults(elem) = Trim(Split(para, ":")(1))
                Next
            End If
        Next
    End With
'    Set mai = Nothing
'    If strResults(0) = "" Then Exit Sub
    ' Only proceed if we have an email address!
    Set nuMai = Application.CreateItem(olMailItem)
    With nuMai
        .To = strResults(0)
        .Subject = "TLN Trade Company Inc - " & strResults(5) & " Your Order has now been shipped by UPS delivery"
        .Body = "Dear " & Split(strResults(4) & " ", " ")(0) & "," & vbCrLf & vbCrLf & _
            "Your order has now been shipped with UPS and is due on to arrive on " & strResults(3) & ".  " & _
            "The tracking number for this order is " & strResults(2) & "." & vbCrLf & vbCrLf & _
            "To check the status of this delivery: " & vbCrLf & vbCrLf & _
            "1.  Go to http://www.ups.com/tracking/tracking.html" & vbCrLf & _
            "2.  Enter the tracking number above in the Tracking or InfoNotice Numbers Box" & vbCrLf & _
            "3.  Press the Track Button" & vbCrLf & vbCrLf & _
            "We would appreciate it if you could let us know when these goods have been delivered to you." & vbCrLf & vbCrLf & _
             "Best regards," & vbCrLf & _
                   "Derek" & vbCrLf & vbCrLf & _

        .Display
    End With

End Sub

Open in new window

UPS-Photo.jpg
0
Comment
Question by:TLN_CANADA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 34240735
Hi, Derek.

Do you have the UPS logo or is it available on the internet somewhere?  If the former, can you upload a copy?  If the latter, can you give me a link to it?
0
 

Author Comment

by:TLN_CANADA
ID: 34241365
Hi BlueDevilFan,

It's on my computer, I may need to resize it a little bit but I think this one is correct.

Thanks,

Derek
ups-resized.jpg
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 34278924
Derek,

Apologies for being slow to get back with you.  Here's the code that produces the message in the screen shot.  All you need to do is edit the path to the server.

Sub editten(mai As Variant)
    Dim para As Variant
    Dim strArray() As String
    Dim nuMai As Object
    Dim strSearchFor() As Variant: strSearchFor = Array("Email:", "Shipping Company:", "Tracking Number:", "Estimated Arrival Date:", "Contact:", "Company Name:")
    Dim strResults() As String
    Dim elem As Integer
    Const str2 As String = ""
    Const str3 As String = ""
    Const str4 As String = ""
    
        ReDim strResults(UBound(strSearchFor))
    '    If TypeName(Application.ActiveWindow) = "Explorer" Then
    '        Set mai = Application.ActiveExplorer.Selection.item(1)
    '    ElseIf TypeName(Application.ActiveWindow) = "Inspector" Then
    '            Set mai = Application.ActiveInspector.CurrentItem
    '    Else
    '        Exit Sub
    '    End If
        With mai
            strArray = Split(.Body, vbCrLf)
            For Each para In strArray
                If para <> "" Then
                    For elem = LBound(strSearchFor) To UBound(strSearchFor)
                        If LCase(Left(para, Len(strSearchFor(elem)))) = LCase(strSearchFor(elem)) Then strResults(elem) = Trim(Split(para, ":")(1))
                    Next
                End If
            Next
        End With
    '    Set mai = Nothing
    '    If strResults(0) = "" Then Exit Sub
        ' Only proceed if we have an email address!
        Set nuMai = Application.CreateItem(olMailItem)
        With nuMai
            .To = strResults(0)
            .Subject = "TLN Trade Company Inc - " & strResults(5) & "Your Order has now been shipped by UPS delivery"
            .HTMLBody = "<table>" _
                      & "<tr><td colspan=""2"">Dear " & Split(strResults(4) & " ", " ")(0) & "Your order has now been shipped with UPS and is due on to arrive on " & strResults(3) & ".  The tracking number for this order is " & strResults(2) & ".<br><br>To check the status of this delivery:<br></td></tr>" _
                      & "<tr><td><img src=""http://www.yourserver.com/images/ups.jpg"" width=""92px"" height=""100px"" /></td><td>1.  Go to http://www.ups.com/tracking/tracking.html<br>2. Enter the tracking number above in the Tracking or InfoNotice Numbers Box<br>3.  Press the Track Button</td></tr>" _
                      & "<tr><td colspan=""2"">We would appreciate it if you could let us know when these goods have been delivered to you.<br><br>Best regards,<br><br>Derek<br><br></td></tr>" _
                      & "</table>"
            .Display
        End With

End Sub

Open in new window

Derek-Message.jpg
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question