R
Richard Stawicki
I'm working on an Outlook 2003 VSTO application to generate an email in a
specified Air Force format. I need the resulting rtf email to be reviewable
before it is sent.
The problem: I'm unable to get multiple attachments to attach where I need
them to be. If there is only one attachment, I have no problem - nor is there
a problem with the "final" attachment in a series.
What I need is this:
3 Tabs:
1. first attached file
2. Second attached file
3. third attached file
-----------------------------------------------------Tab - HB2083_int
First file icon
----------------------------------------------------Tab - testMemo
second file icon
----------------------------------------------------Tab - afman33-326
Third file icon
What I'm getting is this:
3 Tabs:
1. first attached file
2. Second attached file
3. third attached file
-----------------------------------------------------Tab - HB2083_int
---------------Bottom of First file
icon-------------------------------------Tab - testMemo
----------------Bottom of second file
icon------------------------------------Tab - afman33-326
Third file icon
using this code:
_mail.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
If Tabcnt > 0 Then
If Tabcnt = 1 Then
' build array of attachments
fGetTabs(Tabcnt - 1)' build array of attachments
_mail.Body = response & vbCrLf & vbCrLf & "1 Tab:" & vbCrLf
_mail.Body = _mail.Body & TabARry(0, 0) & System.Environment.NewLine
& System.Environment.NewLine & StrDup(53, "-") & "Tab - " &
fGetFileNam(Me.txtTabFile.Text) & System.Environment.NewLine &
System.Environment.NewLine
sBodyLen = _mail.Body.Length
_mail.Attachments.Add(TabARry(0, 1),
Outlook.OlAttachmentType.olByValue, sBodyLen + 1, "attachment name")
Else
_mail.Body = response & vbCrLf & vbCrLf & Tabcnt & " Tabs:" & vbCrLf
ReDim TabARry(Tabcnt - 1, 1)
fGetTabs(Tabcnt - 1) ' build array of attachments
For i = 1 To Tabcnt
_mail.Body = _mail.Body & i & ". " & TabARry(i - 1, 0) & vbCrLf
Next i
For i = 1 To Tabcnt
_mail.Body = _mail.Body & StrDup(2, vbCrLf) & StrDup(53, "-") &
"Tab - " & fGetFileNam(TabARry(i - 1, 1)) & StrDup(2, vbCrLf)
If TabARry(i - 1, 1) = "No File Selected" Then
_mail.Body = _mail.Body & "Attach Document Here"
Else
sBodyLen = _mail.Body.Length
_mail.Attachments.Add(TabARry(i - 1, 1),
Outlook.OlAttachmentType.olByValue, sBodyLen, TabARry(i - 1, 1))
End If
Next i
End If
Else
_mail.Body = response
End If
--- end of code
You might notice that I've been playing with both vbCRLF and
System.Environment.NewLine to see if it might make a difference. I've tried
adding extra lines and subtracing from SBodyLen when I do the attachments,
but that makes no difference.
specified Air Force format. I need the resulting rtf email to be reviewable
before it is sent.
The problem: I'm unable to get multiple attachments to attach where I need
them to be. If there is only one attachment, I have no problem - nor is there
a problem with the "final" attachment in a series.
What I need is this:
3 Tabs:
1. first attached file
2. Second attached file
3. third attached file
-----------------------------------------------------Tab - HB2083_int
First file icon
----------------------------------------------------Tab - testMemo
second file icon
----------------------------------------------------Tab - afman33-326
Third file icon
What I'm getting is this:
3 Tabs:
1. first attached file
2. Second attached file
3. third attached file
-----------------------------------------------------Tab - HB2083_int
---------------Bottom of First file
icon-------------------------------------Tab - testMemo
----------------Bottom of second file
icon------------------------------------Tab - afman33-326
Third file icon
using this code:
_mail.BodyFormat = Outlook.OlBodyFormat.olFormatRichText
If Tabcnt > 0 Then
If Tabcnt = 1 Then
' build array of attachments
fGetTabs(Tabcnt - 1)' build array of attachments
_mail.Body = response & vbCrLf & vbCrLf & "1 Tab:" & vbCrLf
_mail.Body = _mail.Body & TabARry(0, 0) & System.Environment.NewLine
& System.Environment.NewLine & StrDup(53, "-") & "Tab - " &
fGetFileNam(Me.txtTabFile.Text) & System.Environment.NewLine &
System.Environment.NewLine
sBodyLen = _mail.Body.Length
_mail.Attachments.Add(TabARry(0, 1),
Outlook.OlAttachmentType.olByValue, sBodyLen + 1, "attachment name")
Else
_mail.Body = response & vbCrLf & vbCrLf & Tabcnt & " Tabs:" & vbCrLf
ReDim TabARry(Tabcnt - 1, 1)
fGetTabs(Tabcnt - 1) ' build array of attachments
For i = 1 To Tabcnt
_mail.Body = _mail.Body & i & ". " & TabARry(i - 1, 0) & vbCrLf
Next i
For i = 1 To Tabcnt
_mail.Body = _mail.Body & StrDup(2, vbCrLf) & StrDup(53, "-") &
"Tab - " & fGetFileNam(TabARry(i - 1, 1)) & StrDup(2, vbCrLf)
If TabARry(i - 1, 1) = "No File Selected" Then
_mail.Body = _mail.Body & "Attach Document Here"
Else
sBodyLen = _mail.Body.Length
_mail.Attachments.Add(TabARry(i - 1, 1),
Outlook.OlAttachmentType.olByValue, sBodyLen, TabARry(i - 1, 1))
End If
Next i
End If
Else
_mail.Body = response
End If
--- end of code
You might notice that I've been playing with both vbCRLF and
System.Environment.NewLine to see if it might make a difference. I've tried
adding extra lines and subtracing from SBodyLen when I do the attachments,
but that makes no difference.