Msg 22051 Database Mail Attachment file is invalid

Hello,
I'm testing a trigger to output a text file and then attach it to an email in Database Mail. So far, I've gotten the correct text file to export to a TEMP folder, but when I try to attach it to database mail, I get the message below. I think it is a permissions
problem with the TEMP directory, but I've tried adding some permissions, but nothing seems to work. The profile name is TFRONT_DBMAIL and the account name is Albert using Basic Authentication for the SMTP server. I think you have to add the SQL Server User
Account or the Database Mail account to the permissions, but I can't seem to find the exact one to use. I have set up other triggers that use database mail that only send messages with no attachments and they work fine.
Any help appreciated!
Albert
Msg 22051, Level 16, State 1, Line 0
Attachment file "C:\TEMP\NTCDManifestInv135255.txt" is invalid.
Albert S

Hello, I moved the temp file here:
DECLARE
@PathVARCHAR(200)='C:\Users\MSSQLSERVER\Temp\'
SQL Server service account (MSSQLSERVER) has full access to that folder. Still getting this
message:
Msg 22051, Level 16, State 1, Line 0
Attachment file "C:\Users\MSSQLSERVER\Temp\NTCDManifestInv135255.txt" is invalid.
The file is created and it is in the Temp directory. It just won't attach. Thank you
for any help! Below is the full statement.
Albert
DECLARE @CustomerID varchar(10) = 'NTCD'
DECLARE @EmailBody varchar(1000)
DECLARE @CustomerName varchar(50)
DECLARE @InvoiceNo VARCHAR(6) = '135255'
DECLARE @ManifestName VARCHAR(11) = 'ManifestInv'
DECLARE @Extension VARCHAR(4) = '.txt'
DECLARE @FullName VARCHAR(100)
DECLARE @BCP VARCHAR(8000)
DECLARE @Path VARCHAR(200) = 'C:\Users\MSSQLSERVER\Temp\'
SET @FullName = char(34) + @Path + @CustomerID + @ManifestName + CAST(@InvoiceNo as VARCHAR) + @Extension + char(34)
SET @BCP = 'bcp "SELECT char(34)+ComposerAuthor+char(34), char(34)+Title+char(34), char(34)+(ISNULL([Place],char(32))+char(32)+char(58)+char(32) + [Publisher]+char(44)+char(32) + [Copyright])+char(34) AS PlacePubDate, char(36)+CAST([ExtPrice] AS varchar), char(34)+ScoreFormat+char(34) FROM tfront.dbo.tblCustInvItems INNER JOIN tfront.dbo.tblInventory on tfront.dbo.tblCustInvItems.InventoryID = tfront.dbo.tblInventory.ID WHERE InvoiceNo = ' + @InvoiceNo + '" queryout '+ @FullName + ' -T -c -t\t -S'
EXEC master..xp_cmdshell @BCP
SET @EmailBody = 'The Account ' + @CustomerID + ' was billed today.' + Char(13) + 'A text manifest was sent.'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'TFRONT_DBMail',
@recipients = '[email protected]',
@body = @EmailBody,
@subject = 'TFront Database Auto Email',
@file_attachments= @FullName;
Albert S

Similar Messages

  • How to convert Mail attachment file Tab Delimited file to XML.

    Hi PI Experts
        I have XI scenario: MAIL  XI SAP (ABAP Proxy), the process is
    1.     XI will receive tab delimited file as attachment in mail.
    2.     XI will convert the tab delimited file into XML, then map to the target structure.
    3.     Target will be posted into ECC through ABAP Proxy.
    Can anyone help me how can I convert the attachment file (i.e. Tab delimited file) to XML while configuring the sender side.
    Thanks in Advance

    I just grabed what I answered from another thread. It should work.
    Processing sequence as follows:
    1. localejbs/AF_Modules/PayloadSwapBean Local Enterprise Bean swap1
    2. localejbs/AF_Modules/MessageTransformBean Local Enterprise Bean tran1
    3. sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local Enterprise Bean mail
    Module Configuration as follows: Fill the XXXX part with your info.
    swap1 swap.keyName payload-name
    swap1 swap.keyValue MailAttachment-1
    tran1 Transform.Class com.sap.aii.messaging.adapter.Conversion
    tran1 Transform.ContentType ext/xml;charset=utf-8
    tran1 xml.conversionType SimplePlain2XML
    tran1 xml.documentName XXXXXXX_Mail
    tran1 xml.documentNamespace http://XXXXX.com.au/XXXX
    tran1 xml.fieldSeparator \t
    tran1 xml.processFieldNames fromConfiguration
    tran1 xml.structureTitle rows
    Once you set up the above configuration, you will get one record at a time.
    Create a souce message interface like the followings:
    XXXXXXXXX_Mail
    rows
    record
    Target message interface:
    XXXXXXXXX
    rows
    field 1
    field 2
    field 3
    Write a UDF function to remove the TAB space
    public removeTABSpace(String record,Container container){
    //write your code here
    StringTokenizer st = new StringTokenizer(record,"\t",false);
    String t="";
    while (st.hasMoreElements()) t += st.nextElement();
    return t;
    Write another UDF to get the field 1 for example:
    public String getField1(String input,Container container){
    int counter=0;
    int beginIndex=0;
    int endIndex=0;
    int i;
    for (i=0;i<input.length();i++){
    if (input.charAt(i)==34){
    counter=counter+1;
    if (counter==1){
    beginIndex=i+1;
    counter=0;
    break;
    for (i=0;i<input.length();i++){
    if (input.charAt(i)==34){
    counter=counter+1;
    if (counter==2){
    endIndex=i;
    counter=0;
    break;
    input=input.substring(beginIndex,endIndex);
    return input;
    Get the mapping like the followings:
    record - removeTABSpace - getField1 - field 1
    If you need to get field 2, you will need to write another UDF similar to the above one to handle it.

  • Mail attachment file name changes

    when i send mail with attached file having english file name, mail receiver can receive it as correct file name.
    But if having korean file name(ex: 우리나라.doc), recipient receives it as different file name(ie 우리나라.라.doc).
    how can i solve this problem?

    Is the reciever using windows? If so you can choose Edit > Attachments > Always Send Windows Friendly Attachments.

  • Where are apple mail attachment files stored in OS 10.9

    I am trying to locate an attachment file from a recently deleted message.  The message is no longer in my trash, so I can't access the file through Mail.  In the past, there was usually an archived copy somewhere on my hard drive, but it seems to have moved in my most recent update of Mac OSX.  It used to be in the Library folder in my user folder, but now there is no Library folder in that location.  Where do I find these files?

    Go to Finder and select your user/home folder. With that Finder window as the front window, either select Finder/View/Show View options or go command - J.  When the View options opens, check ’Show Library Folder’. That should make your user library folder visible in your user/home folder. Check the Mail folder/V2.
    Thanks to leonie for some information contained in this.

  • In mac mail attachment file showing like pic

    1. Sending file with mac mail its shows like picture
    2. There is paste brush like in MS Office, is it any option available in Mac.
    3. We want to know any option in mac outlook to copy attachment file. (Inbox)
    4. Outlook calendar, any option to enter multiple days’ entry.

    Don't use MS Office, so cannot help you with 2,3 or 4.
    As for 1,  When you attach the file - and it shows as an image, right click/option click on it.  Then select "Show as Icon", and the image will change to a small icon.  Note - this only affects how it appears on your computer - how it appears on the recipients' computer depends on their settings.

  • Java mail + attach files

    hi,
    I have actually two problems:
    1- I want to use a button to view files from the disk, to allow the user to choose files to be attached. I have no idea how to do that.
    2-I am not able to view my mail. my program works but there is always a message from the smtp server : "invalid recipent address", I tried to change servers, change recipient address but I have never received the mail send.
    thank you.

    1. Check javax.swing.JFileChooser
    2. Post the code for setting recipient and put a println of the e-mail address you are trying to set before setting recipient. Be sure to use [c[/i]ode][c[/i]ode] tags when posting code.
    Mike

  • How to upload a PDF document from an e-mail attachment file and convert it to word document for edit

    I received an e-mail.The attachment is in PDF format. I would like to upload the file to convert it to word for editing.How to do that?

    Hi Quincy,
    You would need to save the file to your desktop and upload it from there for conversion using your ExportPDF subscription.
    Let me know if you need further assistance!
    Regards, Stacy

  • Icloud mail attachment file name error

    Here is what i found out on icloud.com using Mozilla Firefox ver 15.
    If attachment name starts with "Print" in iCloud mail, it will not save properly when you click it.
    File name contains only "Print" no matter the length of file name.

    Is the reciever using windows? If so you can choose Edit > Attachments > Always Send Windows Friendly Attachments.

  • Mail attachment file associations gone

    I open dozens of email attachments a day and, until Mavericks, Mail gave me several application options for that purpose. Specifically, I open EPS and PDF files in Illustrator a lot. Now, it only gives me one option (Acrobat) and all the "open with" options that are available elsewhere in the OS are gone. This means every time I open a file I have to browse for the right application. Does anyone know how I can restore these associations?

    Is the reciever using windows? If so you can choose Edit > Attachments > Always Send Windows Friendly Attachments.

  • Download e-mail attached files

    I can't download docs attached to e-mail messages with mail client
    Fxos 1.3

    1) I cannot open .pdf attachments which I receive by email. It seems from the mail from Lorenzo-g that this is not supported by the OS. This is a big handicap!
    2) Worse still, I cannot save the attachments to the SD card. Does anyone know how to do this? Or is extracting attachments not supported by the OS?
    3) If I cannot read or extract the attachment, then I want to be able to forward it to another email address to read there. But when I try I get the message "attachments cannot be forwarded". Is there no way around this problem?
    I would really like Firefox OS to be a success!
    I use an Alcatel onetouch fire with OS1.3.0.0 firmware revision 02 004 hardware revision 08

  • I can no longer attach files in Yahoo mail since upgrading to FireFox 4.0.1. I click the "attach" button and nothing happens - no file list to select from appears; nothing.

    Since upgrading to Firefox 4.0.1 the "attach files" function in my Yahoo Mail account no longer functions. When I click the "attach files" button nothing happens - nothing. No file selection box opens, no error message appears, no pinwheel of death, nothing.
    The "attach files" button is no longer 'hot' in FF 4.0.1 either = the "little hand" icon does not appear when I scroll over it. Other action buttons are still 'hot' ("attachments", "emoticons", "format", "hide bcc"etc.) - just not the "attach files" button.
    The Yahoo Mail "attach files" function still works when I use my Safari browser, however. So, it appears to be a FF4.0.1 issue.
    (Intel MacBook, Snow Leopard, 2gb ram, 360gb hd)

    You can try to delete the file mimeTypes.rdf
    See "Reset Download Actions"
    * http://kb.mozillazine.org/File_types_and_download_actions

  • Attaching files crashes Mac Mail and Thunderbird

    Just upgraded from Mountain Lion to Mavericks 10.9.3 on a 2012 Mac Mini 4 core.  When attempting to add an attachment to an email, both Mac Mail and Thunderbird start with the spinning beachball and never recover.  Force Quit is the only option.  Even after that, the Finder has strange screen artifacts left over from Mail (attach file dialog box) and Finder must be relaunched as well.
    Dragging and dropping files works okay with Mac Mail.  This option does not exist when using Thunderbird, so no workaround available for that App.  Also, Mac Mail only gets stuck when attempting to attach files on the desktop.  Files from other locations attach OK.
    Already tried Repair Permissions, Repair Disk, Reinstalled Mavericks with no change.  For now, I have gone back to Mountain Lion since this is a deal breaker, even though everything else seems to work ok (except for the occasional brief spinning beach ball).

    1. This procedure is a diagnostic test. It changes nothing, for better or worse, and therefore will not, in itself, solve the problem. But with the aid of the test results, the solution may take a few minutes, instead of hours or days.
    2. If you don't already have a current backup, back up all data before doing anything else. The backup is necessary on general principle, not because of anything in the test procedure. Backup is always a must, and when you're having any kind of trouble with the computer, you may be at higher than usual risk of losing data, whether you follow these instructions or not.
    There are ways to back up a computer that isn't fully functional. Ask if you need guidance.
    3. Below are instructions to run a UNIX shell script, a type of program. All it does is to collect information about the state of the computer. That information goes nowhere unless you choose to share it. However, you should be cautious about running any kind of program (not just a shell script) at the behest of a stranger. If you have doubts, search this site for other discussions in which this procedure has been followed without any report of ill effects. If you can't satisfy yourself that the instructions are safe, don't follow them. Ask for other options.
    Here's a summary of what you need to do, if you choose to proceed:
    ☞ Copy a line of text in this window to the Clipboard.
    ☞ Paste into the window of another application.
    ☞ Wait for the test to run. It usually takes a few minutes.
    ☞ Paste the results, which will have been copied automatically, back into a reply on this page.
    The sequence is: copy, paste, wait, paste again. You don't need to copy a second time. Details follow.
    4. You may have started the computer in "safe" mode. Preferably, these steps should be taken in “normal” mode, under the conditions in which the problem is reproduced. If the system is now in safe mode and works well enough in normal mode to run the test, restart as usual. If you can only test in safe mode, do that.
    5. If you have more than one user, and the one affected by the problem is not an administrator, then please run the test twice: once while logged in as the affected user, and once as an administrator. The results may be different. The user that is created automatically on a new computer when you start it for the first time is an administrator. If you can't log in as an administrator, test as the affected user. Most personal Macs have only one user, and in that case this section doesn’t apply. Don't log in as root.
    6. The script is a single long line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, though you may not see all of it in the browser window, and you can then copy it. If you try to select the line by dragging across the part you can see, you won't get all of it.
    Triple-click anywhere in the line of text below on this page to select it:
    PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/libexec;clear;cd;p=(Software Hardware Memory Diagnostics Power FireWire Thunderbolt USB Fonts 51 4 1000 25 5120 KiB/s 1024 85 \\b%% 20480 1 MB/s 25000 ports 'com.autodesk.AutoCad com.evenflow.dropbox com.google.GoogleDrive' DYLD_INSERT_LIBRARIES\ DYLD_LIBRARY_PATH -86 ` route -n get default|awk '/e:/{print $2}' ` 25 N\\/A down up 102400 25600 recvfrom sendto CFBundleIdentifier 25 25 25 1000 MB );N5=${#p[@]};p[N5]=` networksetup -listnetworkserviceorder|awk ' NR>1 { sub(/^\([0-9]+\) /,"");n=$0;getline;} $NF=="'${p[26]}')" { sub(/.$/,"",$NF);print n;exit;} ' `;f=('\n%s: %s\n' '\n%s\n\n%s\n' '\nRAM details\n%s\n' %s\ %s '%s\n\t(%s)\n' );S0() { echo ' { q=$NF+0;$NF="";u=$(NF-1);$(NF-1)="";gsub(/^ +| +$/,"");if(q>='${p[$1]}') printf("%s (UID %s) is using %s '${p[$2]}'",$0,u,q);} ';};s=(' /^ *$|CSConfigDot/d;s/^ */   /;s/[-0-9A-Fa-f]{22,}/UUID/g;s/(ochat)\.[^.]+(\..+)/\1\2/;/Shared/!s/\/Users\/[^/]+/~/g ' ' s/^ +//;5p;6p;8p;12p;' ' {sub(/^ +/,"")};NR==6;NR==13&&$2<'${p[10]} ' 1s/://;3,6d;/[my].+:/d;s/^ {4}//;H;${ g;s/\n$//;/s: [^EO]|x([^08]|02[^F]|8[^0])/p;} ' ' 5h;6{ H;g;/P/!p;} ' ' ($1~/^Cy/&&$3>'${p[11]}')||($1~/^Cond/&&$2!~/^N/) ' ' /:$/{ N;/:.+:/d;s/ *://;b0'$'\n'' };/^ *(V.+ [0N]|Man).+ /{ s/ 0x.... //;s/[()]//g;s/(.+: )(.+)/ (\2)/;H;};$b0'$'\n'' d;:0'$'\n'' x;s/\n\n//;/Apple[ ,]|Intel|SMSC/d;s/\n.*//;/\)$/p;' ' s/^.*C/C/;H;${ g;/No th|pms/!p;} ' '/= [^GO]/p' '{$1=""};1' ' /Of/!{ s/^.+is |\.//g;p;} ' ' $0&&!/ / { n++;print;} END { if(n<200) print "com.apple.";} ' ' $3~/[0-9]:[0-9]{2}$/ { gsub(/:[0-9:a-f]{14}/,"");} { print|"tail -n'${p[12]}'";} ' ' NR==2&&$4<='${p[13]}' { print $4;} ' ' END { $2/=256;if($2>='${p[15]}') print int($2) } ' ' NR!=13{next};{sub(/[+-]$/,"",$NF)};'"`S0 21 22`" 'NR!=2{next}'"`S0 37 17`" ' NR!=5||$8!~/[RW]/{next};{ $(NF-1)=$1;$NF=int($NF/10000000);for(i=1;i<=3;i++){$i="";$(NF-1-i)="";};};'"`S0 19 20`" 's:^:/:p' '/\.kext\/(Contents\/)?Info\.plist$/p' 's/^.{52}(.+) <.+/\1/p' ' /Launch[AD].+\.plist$/ { n++;print;} END { if(n<200) print "/System/";} ' '/\.xpc\/(Contents\/)?Info\.plist$/p' ' NR>1&&!/0x|\.[0-9]+$|com\.apple\.launchctl\.(Aqua|Background|System)$/ { print $3;} ' ' /\.(framew|lproj)|\):/d;/plist:|:.+(Mach|scrip)/s/:[^:]+//p ' '/root/p' ' !/\/Contents\/.+\/Contents|Applic|Autom|Frameworks/&&/Lib.+\/Info.plist$/ { n++;print;} END { if(n<1000) print "/System/";} ' '/^\/usr\/lib\/.+dylib$/p' ' /Temp|emac/d;/(etc|Preferences)\//s/^\.\/[^/]+//p;' ' /\/(Contents\/.+\/Contents|Frameworks)\/|\.wdgt\/.+\.[bw]/d;p;' 's/\/(Contents\/)?Info.plist$//;p' ' { gsub("^| ","||kMDItem'${p[35]}'=");sub("^.."," ") };1 ' p '{print $3"\t"$1}' 's/\'$'\t''.+//p' 's/1/On/p' '/Prox.+: [^0]/p' '$2>'${p[9]}'{$2=$2-1;print}' ' BEGIN { i="'${p[26]}'";M1='${p[16]}';M2='${p[18]}';M3='${p[31]}';M4='${p[32]}';} !/^A/ { next;} /%/ { getline;if($5<M1) a="user "$2"%, system "$4"%";} /disk0/&&$4>M2 { b=$3" ops/s, "$4" blocks/s";} $2==i { if(c) { d=$3+$4+$5+$6;next;};if($4>M3||$6>M4) c=int($4/1024)" in, "int($6/1024)" out";} END { if(a) print "CPU: "a;if(b) print "I/O: "b;if(c) print "Net: "c" (KiB/s)";if(d) print "Net errors: "d" packets/s";} ' ' /r\[0\] /&&$NF!~/^1(0|72\.(1[6-9]|2[0-9]|3[0-1])|92\.168)\./ { print $NF;exit;} ' ' !/^T/ { printf "(static)";exit;} ' '/apsd|OpenD/!s/:.+//p' ' (/k:/&&$3!~/(255\.){3}0/ )||(/v6:/&&$2!~/A/ ) ' ' $1~"lR"&&$2<='${p[25]}';$1~"li"&&$3!~"wpa2";' ' BEGIN { FS=":";} { n=split($3,a,".");sub(/_2[01].+/,"",$3);print $2" "$3" "a[n]" "$1;b=b$1;} END { if(b) print("\n\t* Code injection");} ' ' NR!=4{next} {$NF/=10240} '"`S0 27 14`" ' END { if($3~/[0-9]/)print$3;} ' ' BEGIN { L='${p[36]}';} !/^[[:space:]]*(#.*)?$/ { l++;if(l<=L) f=f"\n   "$0;} END { F=FILENAME;if(!F) exit;if(!f) f="\n   [N/A]";"file -b "F|getline T;if(T!~/^(AS.+ (En.+ )?text$|POSIX sh.+ text ex)/) F=F" ("T")";printf("\nContents of %s\n%s\n",F,f);if(l>L) printf("\n   ...and %s more line(s)\n",l-L);} ' ' BEGIN{FS="= "} /Path/{print $2} ' ' /^ +B/{ s/.+= |(-[0-9]+)?\.s.+//g;p;} ' ' END{print NR} ' ' /id: N|te: Y/{i++} END{print i} ' ' / /{$0="'"${p[28]}"'"};1;' '/ en/!s/\.//p' ' NR!=13{next};{sub(/[+-M]$/,"",$NF)};'"`S0 39 40`" ' $10~/\(L/&&$9!~"localhost" { sub(/.+:/,"",$9);print $1": "$9;} ' '/^ +r/s/.+"(.+)".+/\1/p' 's/(.+\.wdgt)\/(Contents\/)?Info\.plist$/\1/p' 's/^.+\/(.+)\.wdgt$/\1/p' );c1=(system_profiler pmset\ -g nvram fdesetup find syslog df vm_stat sar ps sudo\ crontab sudo\ iotop top pkgutil PlistBuddy whoami cksum kextstat launchctl sudo\ launchctl crontab 'sudo defaults read' stat lsbom mdfind ' for i in ${p[24]};do ${c1[18]} ${c2[27]} $i;done;' defaults\ read scutil sudo\ dtrace sudo\ profiles sed\ -En awk /S*/*/P*/*/*/C*/*/airport networksetup mdutil sudo\ lsof test );c2=(com.apple.loginwindow\ LoginHook '-c Print /L*/P*/loginw*' '-c Print L*/P*/*loginit*' '-c Print L*/Saf*/*/E*.plist' '~ $TMPDIR.. \( -flags +sappnd,schg,uappnd,uchg -o ! -user $UID -o ! -perm -600 \)' '.??* -path .Trash -prune -o -type d -name *.app -print -prune' '-c Print\ :'${p[35]}' 2>&1' '-c Print\ :Label 2>&1' '{/,}L*/{Con,Pref}* -type f ! -size 0 -name *.plist -exec plutil -s {} \;' "-f'%N: %l' Desktop L*/Keyc*" therm sysload boot-args status " -F '\$Time \$Message' -k Sender kernel -k Message Req 'Beac|caug|dead[^bl]|FAIL|GPU |hfs: Ru|inval|jnl:|last value [1-9]|n Cause: -|NVDA\(|pagin|proc: t|Roamed|rror|ssert|Thrott|tim(ed? ?|ing )o|WARN' -k Message Rne 'Goog|ksadm|SMC:' -o -k Sender fseventsd -k Message Req 'SL' " '-du -n DEV -n EDEV 1 10' 'acrx -o comm,ruid,%cpu' '-t1 10 1' '-f -pfc /var/db/r*/com.apple.*.{BS,Bas,Es,OSXU,Rem,up}*.bom' '{/,}L*/Lo*/Diag* -type f -regex .\*[cgh] ! -name *ag \( -exec grep -lq "^Thread c" {} \; -exec printf \* \; -o -true \) -execdir stat -f:%Sc:%N -t%F {} \;|sort -t: -k2 |tail -n'${p[38]} '-L {/{S*/,},}L*/Lau* -type f' '-L /{S*/,}L*/StartupItems -type f -exec file {} +' '-L /S*/L*/{C*/Sec*A,E}* {/,}L*/{A*d,Ca*/*/Ex,Compon,Ex,In,iTu,Keyb,Mail/B,P*P,Qu*T,Scripti,Sec,Servi,Spo,Widg}* -type f -name Info.plist' '/usr/lib -type f -name *.dylib' `awk "${s[31]}"<<<${p[23]}` "/e*/{auto,{cron,fs}tab,hosts,[lps]*.conf,pam.d,ssh{,d}_config,*.local} {,/usr/local}/etc/periodic/*/* /L*/P*{,/*}/com.a*.{Bo,sec*.ap}* .launchd.conf" list getenv /Library/Preferences/com.apple.alf\ globalstate --proxy '-n get default' -I --dns -getdnsservers -getinfo\ "${p[N5]}" -P -m\ / '' -n1 '-R -l1 -n1 -o prt -stats command,uid,prt' '--regexp --only-files --files com.apple.pkg.*|sort|uniq' -kl -l -s\ / '-R -l1 -n1 -o mem -stats command,uid,mem' -i4TCP:0-1023 com.apple.dashboard\ layer-gadgets '-d /L*/Mana*/$USER&&echo On' );N1=${#c2[@]};for j in {0..8};do c2[N1+j]=SP${p[j]}DataType;done;N2=${#c2[@]};for j in 0 1;do c2[N2+j]="-n ' syscall::'${p[33+j]}':return { @out[execname,uid]=sum(arg0) } tick-10sec { trunc(@out,1);exit(0);} '";done;l=(Restricted\ files Hidden\ apps 'Elapsed time (s)' POST Battery Safari\ extensions Bad\ plists 'High file counts' User Heat System\ load boot\ args FileVault Diagnostic\ reports Log 'Free space (MiB)' 'Swap (MiB)' Activity 'CPU per process' Login\ hook 'I/O per process' Mach\ ports kexts Daemons Agents launchd Startup\ items Admin\ access Root\ access Bundles dylibs Apps Font\ issues Inserted\ dylibs Firewall Proxies DNS TCP/IP Wi-Fi Profiles Root\ crontab User\ crontab 'Global login items' 'User login items' Spotlight Memory Listeners Widgets Parental\ Controls );N3=${#l[@]};for i in 0 1 2;do l[N3+i]=${p[5+i]};done;N4=${#l[@]};for j in 0 1;do l[N4+j]="Current ${p[29+j]}stream data";done;A0() { id -G|grep -qw 80;v[1]=$?;((v[1]==0))&&sudo true;v[2]=$?;v[3]=`date +%s`;clear >&-;date '+Start time: %T %D%n';};for i in 0 1;do eval ' A'$((1+i))'() { v=` eval "${c1[$1]} ${c2[$2]}"|'${c1[30+i]}' "${s[$3]}" `;[[ "$v" ]];};A'$((3+i))'() { v=` while read i;do [[ "$i" ]]&&eval "${c1[$1]} ${c2[$2]}" \"$i\"|'${c1[30+i]}' "${s[$3]}";done<<<"${v[$4]}" `;[[ "$v" ]];};A'$((5+i))'() { v=` while read i;do '${c1[30+i]}' "${s[$1]}" "$i";done<<<"${v[$2]}" `;[[ "$v" ]];};';done;A7(){ v=$((`date +%s`-v[3]));};B2(){ v[$1]="$v";};for i in 0 1;do eval ' B'$i'() { v=;((v['$((i+1))']==0))||{ v=No;false;};};B'$((3+i))'() { v[$2]=`'${c1[30+i]}' "${s[$3]}"<<<"${v[$1]}"`;} ';done;B5(){ v[$1]="${v[$1]}"$'\n'"${v[$2]}";};B6() { v=` paste -d: <(printf "${v[$1]}") <(printf "${v[$2]}")|awk -F: ' {printf("'"${f[$3]}"'",$1,$2)} ' `;};B7(){ v=`grep -Fv "${v[$1]}"<<<"$v"`;};C0(){ [[ "$v" ]]&&echo "$v";};C1() { [[ "$v" ]]&&printf "${f[$1]}" "${l[$2]}" "$v";};C2() { v=`echo $v`;[[ "$v" != 0 ]]&&C1 0 $1;};C3() { v=`sed -E "$s"<<<"$v"`&&C1 1 $1;};for i in 1 2;do for j in 2 3;do eval D$i$j'(){ A'$i' $1 $2 $3; C'$j' $4;};';done;done;{ A0;A2 0 $((N1+1)) 2;C0;A1 0 $N1 1;C0;B0;C2 27;B0&&! B1&&C2 28;D12 15 37 25 8;A1 0 $((N1+2)) 3;C0;D13 0 $((N1+3)) 4 3;D23 0 $((N1+4)) 5 4;for i in 0 1 2;do D13 0 $((N1+5+i)) 6 $((N3+i));done;D13 1 10 7 9;D13 1 11 8 10;D22 2 12 9 11;D12 3 13 10 12;D23 4 19 44 13;D23 5 14 12 14;D22 6 36 13 15;D22 7 37 14 16;D23 8 15 38 17;D22 9 16 16 18;B1&&{ D22 11 17 17 20;for i in 0 1;do D22 28 $((N2+i)) 45 $((N4+i));done;};D22 12 44 54 45;D22 12 39 15 21;A1 13 40 18;B2 4;B3 4 0 19;A3 14 6 32 0;B4 0 5 11;A1 17 41 20;B7 5;C3 22;B4 4 6 21;A3 14 7 32 6;B4 0 7 11;B3 4 0 22;A3 14 6 32 0;B4 0 8 11;B5 7 8;B1&&{ A2 19 26 23;B7 7;C3 23;};A2 18 26 23;B7 7;C3 24;A2 4 20 21;B7 6;B2 9;A4 14 7 52 9;B2 10;B6 9 10 4;C3 25;D13 4 21 24 26;B4 4 12 26;B3 4 13 27;A1 4 22 29;B7 12;B2 14;A4 14 6 52 14;B2 15;B6 14 15 4;B3 0 0 30;C3 29;A1 4 23 27;B7 13;C3 30;D13 24 24 32 31;D13 25 37 32 33;A1 23 18 28;B2 16;A2 16 25 33;B7 16;B3 0 0 34;B2 21;A6 47 21&&C0;B1&&{ D13 21 0 32 19;D13 10 42 32 40;D22 29 35 46 39;};D23 14 1 48 42;D12 34 43 53 44;D22 0 $((N1+8)) 51 32;D13 4 8 41 6;D12 26 28 35 34;D13 27 29 36 35;A2 27 32 39&&{ B2 19;A2 33 33 40;B2 20;B6 19 20 3;};C2 36;D23 33 34 42 37;B1&&D23 35 45 55 46;D23 32 31 43 38;D12 36 47 32 48;D13 20 42 32 41;D23 14 2 48 43;D13 4 5 32 1;D22 4 4 50 0;D13 14 3 49 5;B3 4 22 57;A1 26 46 56;B7 22;B3 0 0 58;C3 47;D23 22 9 37 7;A7;C2 2;} 2>/dev/null|pbcopy;exit 2>&-  
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    7. Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Click anywhere in the Terminal window and paste by pressing command-V. The text you pasted should vanish immediately. If it doesn't, press the return key.
    8. If you see an error message in the Terminal window such as "syntax error," enter
    exec bash
    and press return. Then paste the script again.
    9. If you're logged in as an administrator, you'll be prompted for your login password. Nothing will be displayed when you type it. You will not see the usual dots in place of typed characters. Make sure caps lock is off. Type carefully and then press return. You may get a one-time warning to be careful. If you make three failed attempts to enter the password, the test will run anyway, but it will produce less information. In most cases, the difference is not important. If you don't know the password, or if you prefer not to enter it, press the key combination control-C or just press return three times at the password prompt. Again, the script will still run.
    If you're not logged in as an administrator, you won't be prompted for a password. The test will still run. It just won't do anything that requires administrator privileges.
    10. The test may take a few minutes to run, depending on how many files you have and the speed of the computer. A computer that's abnormally slow may take longer to run the test. While it's running, there will be nothing in the Terminal window and no indication of progress. Wait for the line
    [Process completed]
    to appear. If you don't see it within half an hour or so, the test probably won't complete in a reasonable time. In that case, close the Terminal window and report the results. No harm will be done.
    11. When the test is complete, quit Terminal. The results will have been copied to the Clipboard automatically. They are not shown in the Terminal window. Please don't copy anything from there. All you have to do is start a reply to this comment and then paste by pressing command-V again.
    At the top of the results, there will be a line that begins with "Model Identifier." If you don't see that, but instead see a mass of gibberish, you didn't wait for the "Process completed" message to appear in the Terminal window. Please wait for it and try again.
    If any private information, such as your name or email address, appears in the results, anonymize it before posting. Usually that won't be necessary.
    12. When you post the results, you might see the message, "You have included content in your post that is not permitted." It means that the forum software has misidentified something in the post as a violation of the rules. If that happens, please post the test results on Pastebin, then post a link here to the page you created.
    Note: This is a public forum, and others may give you advice based on the results of the test. They speak only for themselves, and I don't necessarily agree with them.
    Copyright © 2014 by Linc Davis. As the sole author of this work, I reserve all rights to it except as provided in the Use Agreement for the Apple Support Communities website ("ASC"). Readers of ASC may copy it for their own personal use. Neither the whole nor any part may be redistributed.

  • How to mail pdf file from oracle database 11g

    Hi,
    Using following code to send pdf file from oracle database.
    DECLARE
    v_From VARCHAR2(80) := '[email protected]';
    v_Recipient VARCHAR2(80) := '[email protected]';
    v_Subject VARCHAR2(80) := 'test subject';
    v_Mail_Host VARCHAR2(30) := '116.214.31.249';
    v_Mail_Conn sys.utl_smtp.Connection;
    crlf VARCHAR2(2) := chr(13)||chr(10);
    BEGIN
    v_Mail_Conn := sys.utl_smtp.Open_Connection(v_Mail_Host, 26);
    sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
    sys.utl_smtp.Mail(v_Mail_Conn, v_From);
    sys.utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
    sys.utl_smtp.Data(v_Mail_Conn,
    'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: ' || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: ' || v_Recipient || crlf ||
    'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
    'Content-Type: multipart/mixed;'|| crlf ||
    ' boundary="-----SECBOUND"'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    'Content-Transfer_Encoding: 7bit'|| crlf ||
    crlf ||
    'some message text'|| crlf ||     -- Message body
    'more message text'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: file;'|| crlf ||
    ' name="D:\mail\pdfSample.pdf"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="D:\mail\pdfSample.pdf"'|| crlf ||
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachment
    crlf ||
    '-------SECBOUND--'               -- End MIME mail
    sys.utl_smtp.Quit(v_mail_conn);
    EXCEPTION
    WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    Above code executed successfully and mail is send to recipient but file is corrupted.
    I think it doesn't pick file from specified location, attachment name is appearing like this 'D:mailpdfsample.pdf
    Oracle Database : 11g R2
    O.S : windows 7 Professional
    Thanks in Advance

    parapr wrote:
    sys.utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);The above violates RFC 5321 section 4.1.1.1
    '-------SECBOUND'|| crlf ||
    'Content-Type: file;'|| crlf ||
    ' name="D:\mail\pdfSample.pdf"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="D:\mail\pdfSample.pdf"'|| crlf ||Invalid Mime header above. Filename are logical. Not physical. Loose the drive and directory names. The filename is there to name the Mime body's content.
    crlf ||
    'CSV,file,attachement'|| crlf ||     -- Content of attachmentHow is the above PDF content? This is a string containing the text CSV,file,attachement. Which means when this is what is saved as a PDF file by the mail reader.
    EXCEPTION
    WHEN sys.utl_smtp.Transient_Error OR sys.utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;Silly. Why change meaningful exceptions into a generic meaningless exception?? That does not make any sense.

  • Need to get the Mail attachment name as it is to the receiver file adapter

    I am doing a Mail to File scenario. I need to get the attachment from the mail and store it on the file server. I am using the PayloadSwap bean in the sender mail adapter. My requirement is to carry forward the attachement name as it is to the receiver file adapter side and store the file with the same name.
    Did any one try doing this? I was looking at developing an adapter module but got struck as I could not find whether the attachement name is stored in the XI payload after it has got swapped using the swap bean.
    Any help would be appreciated.
    VJ

    Oops pressed the send key. Take two.
    This is becoming a damn nightmare. When I run the adapter I am getting ModuleExceptions. Can you pass your eyes over these Java config settings to see what I am doing wrong. Using NWDS CE 7.1 with PI 7.1 both at SP07. All the imports were taken from PI 7.1 after SP07 was applied. The build id of NWDS is
    SAP NetWeaver Developer Studio
    SAP NetWeaver 7.1 Composition Environment SP07 PAT0001
    Build id: 200901152336
    APPLICATION.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
    "http://java.sun.com/dtd/application_1_3.dtd">
    <application>
    <display-name>MailPOP_EAR</display-name>
    <description>EAR description</description>
    <module>
    <ejb>MailPOP_EJB.jar</ejb>
    </module>
    </application>
    APPLICATION-J2EE-ENGINE.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application-j2ee-engine SYSTEM "application-j2ee-engine.dtd">
    <application-j2ee-engine>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="service">engine.security.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="library">engine.j2ee14.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="service">com.sap.aii.af.svc.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="interface">com.sap.aii.af.ifc.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="library">com.sap.aii.af.lib.facade</reference-target>
    </reference>
    <reference reference-type="hard">
    <reference-target provider-name="sap.com" target-type="library">com.sap.base.technology.facade</reference-target>
    </reference>
    <fail-over-enable mode="disable" />
    </application-j2ee-engine>
    EJB-J2EE-ENGINE.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-j2ee-engine SYSTEM "ejb-j2ee-engine.dtd">
    <ejb-j2ee-engine>
    <enterprise-beans>
    <enterprise-bean>
    <ejb-name>GetMailAttachment</ejb-name>
    <jndi-name>GetMailAttachment</jndi-name>
    <session-props/>
    </enterprise-bean>
    </enterprise-beans>
    </ejb-j2ee-engine>
    EJB-JAR.XML
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
    2.0//EN"
    "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <description>EJB JAR description</description>
    <display-name>EJB JAR</display-name>
    <enterprise-beans>
    <session>
    <ejb-name>GetMailAttachment</ejb-name>
    <home>com.sap.aii.af.lib.mp.module.ModuleHome</home>
    <remote>com.sap.aii.af.lib.mp.module.ModuleRemote</remote>
    <local-home>com.sap.aii.af.lib.mp.module.ModuleLocalHome</local-home>
    <local>com.sap.aii.af.lib.mp.module.ModuleLocal</local>
    <ejb-class>sample.GetMailAttachment</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    SENDER MAIL ADAPTER modules
    1 AF_Modules/PayloadSwapBean Local EB 1
    2 GetMailAttachment Local EB 2
    3 sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean Local EB 3
    1     swap.keyName          payload-name
    1     swap.keyValue          MailAttachment-1
    RECEIVER FILE MODULES
    1     localejbs/AF_Modules/DynamicConfigurationBean     Local Enterprise Bean     1
    2     localejbs/CallSapAdapter                    Local Enterprise Bean     2
    1     key.0          write http://sap.com/xi/XI/System/File FileName
    1     value.0          message.interface
    VARIABLE FILENAME SUBST WITH ASMA TURNED ON
    fName     message:interface_name
    JAVA SOURCE
    package sample;
    import javax.ejb.CreateException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import com.sap.aii.af.lib.mp.module.Module;
    import com.sap.aii.af.lib.mp.module.ModuleContext;
    import com.sap.aii.af.lib.mp.module.ModuleData;
    import com.sap.aii.af.lib.mp.module.ModuleException;
    import com.sap.engine.interfaces.messaging.api.Message;
    import com.sap.engine.interfaces.messaging.api.MessagePropertyKey;
    import com.sap.engine.interfaces.messaging.api.TextPayload;
    import com.sap.engine.interfaces.messaging.api.XMLPayload;
    import com.sap.aii.af.service.cpa.Channel;
    @ejbHome <{com.sap.aii.af.lib.mp.module.ModuleHome}>
    @ejbLocal <{com.sap.aii.af.lib.mp.module.ModuleLocal}>
    @ejbLocalHome <{com.sap.aii.af.lib.mp.module.ModuleLocalHome}>
    @ejbRemote <{com.sap.aii.af.lib.mp.module.ModuleRemote}>
    @stateless
    <code>GetMailAttachment</code>
    @SuppressWarnings("unused")
    public class GetMailAttachment implements SessionBean, Module {
         private static final long serialVersionUID = 7612238514043673502L;
         private SessionContext myContext;
         private MessagePropertyKey myFileName;
         public void ejbRemove() {
         public void ejbActivate() {
         public void ejbPassivate() {
         public void setSessionContext(SessionContext context) {
              myContext = context;
    @throws CreateException
         public void ejbCreate() throws CreateException {
         public void getMessageProperty(MessagePropertyKey FileName) {
              myFileName = FileName;
    @param moduleContext
               Contains data of the module processor that might be important
               for the module implementation such as current channel ID
    @param inputModuleData
               Contains the input XI message as principal data plus eventual
               set supplemental data
    @return ModuleData Contains the (changed) output XI message. Might be the
            response message if the module is the last in the chain.
    @exception ModuleException
                   Describes the cause of the exception and indicates whether
                   an retry is sensible or not.
         @SuppressWarnings("deprecation")
         public ModuleData process(ModuleContext moduleContext,
                   ModuleData inputModuleData) throws ModuleException {
              try {
                   Message msg = (Message) inputModuleData.getPrincipalData();
                   TextPayload payload = msg.getDocument();
                   String contentType = payload.getContentType();
                   // Content Type could be something like
                   // text/plain;charset="UTF-8";name="file.txt"
                   contentType = contentType.replaceAll("\"", "");
                   int i = contentType.lastIndexOf("=") + 1;
                   String fileName = contentType.substring(i);
                   msg.setMessageProperty(myFileName, fileName);
                   inputModuleData.setPrincipalData(msg);
              } catch (Exception e) {
              return inputModuleData;
    JAVA ERRORS
    2009-02-04 11:41:14     Information     Mail: calling the module processor for channel LMK_Common_Mail_Sender
    2009-02-04 11:41:14     Information     Swap: swapping by payload-name ? MailAttachment-1
    2009-02-04 11:41:14     Information     Swap: successfully swapped
    2009-02-04 11:41:14     Information     Mail: message leaving the adapter (call)
    2009-02-04 11:41:14     Information     The application tries to send an XI message asynchronously using connection AFW.
    2009-02-04 11:41:14     Information     Backward validation is enabled
    2009-02-04 11:41:14     Error     Unable to validate the message with message ID 8702df71-f254-11dd-9b9b-001a64a73518
    2009-02-04 11:41:14     Error     Returning to application. Exception: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Content is not allowed in prolog.
    2009-02-04 11:41:14     Error     Mail: error occured: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Content is not allowed in prolog.
    2009-02-04 11:41:14     Error     Mail: error occured: com.sap.aii.af.lib.mp.module.ModuleException

  • Javax.mail CSV file attachment corrupt?

    I'm having some trouble with attaching a file to an outgoing email, it's a CSV file and when it is uploaded/attached to the email, it becomes "corrupt". Excel will still open it but if I open it in notepad the formatting is noticeably messed up. I need it to retain all the correct return carriages and line feeds, which I believe are what are getting mingled. (Another program must read it and this formatting is messing everything up).
    Here's the code:
    MimeBodyPart messageBodyPart =
                     new MimeBodyPart();
             //fill message
             messageBodyPart.setText(outBoundMessage);
             Multipart multipart = new MimeMultipart();
             multipart.addBodyPart(messageBodyPart);
             if (fileAttachment != null) {
                // Part two is attachment
                MimeBodyPart attachment = new MimeBodyPart();
                attachment.attachFile(fileAttachment);
                attachment.setFileName(fileAttachment.getName());
                attachment.setHeader("type", "text/csv");
                multipart.addBodyPart(attachment);
             // Put parts in message
             message.setContent(multipart);The other parts of the message are being created and attached where necessary. My guess is that it's not transferring in binary? I've never really done this sort of thing so if anyone could lend a hand and show me how to properly attach files so they don't get altered in anyway I would greatly appreciate it.

    Hi,
    I am sending csv file as an attachment by using below code
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class AttchmtMail
        String finaldt;
            public  void mailAtchmt(String fname,String dt) {
                String   to="[email protected]";
               String from = "[email protected]";
              String to2="[email protected]";
                 String host = "xxx.xx.xxx.xxx";
                // Create properties, get Session
                Properties props = new Properties();
                // If using static Transport.send(),
                // need to specify which host to send it to
                props.put("mail.smtp.host", host);
                // To see what is going on behind the scene
                props.put("mail.debug", "true");
                Session session = Session.getInstance(props);
                try {
                    // Instantiatee a message
                    Transport bus = session.getTransport("smtp");
                    bus.connect();
                    Message msg = new MimeMessage(session);
                    //Set message attributes
                    msg.setFrom(new InternetAddress(from));
                    InternetAddress[] address = {new InternetAddress(to),new InternetAddress(to2)};
                    msg.setRecipients(Message.RecipientType.TO, address);
                    msg.setSubject("New OU's on "+dt+".");
                    msg.setSentDate(new Date());
                   // String filename= "C:/Feeds/"+finaldt+"/"+files;
    String file1= fname;
    File f1=new File(file1);
    if(f1.exists())
    setFileAsAttachment(msg, file1);
    else
    //setFileAsAttachment(msg,"","",info);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    bus.close();
    catch (MessagingException mex) {
    // Prints all nested (chained) exceptions as well
    mex.printStackTrace();
    // How to access nested exceptions
    while (mex.getNextException() != null) {
    // Get next exception in chain
    Exception ex = mex.getNextException();
    ex.printStackTrace();
    if (!(ex instanceof MessagingException)) break;
    else mex = (MessagingException)ex;
    public void setFileAsAttachment(Message msg, String filename)
    throws MessagingException {
    // Create and fill first part
    MimeBodyPart p1 = new MimeBodyPart();
    p1.setText("Dear ,\n\nPlease check the attachment " );
    // Create second part
    MimeBodyPart p2 = new MimeBodyPart();
    // Put a file in the second part
    if(!filename.equals(""))
    FileDataSource fds = new FileDataSource(filename);
    p2.setDataHandler(new DataHandler(fds));
    p2.setFileName(fds.getName());
    // Create the Multipart. Add BodyParts to it.
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    if(!filename.equals(""))
    mp.addBodyPart(p2);
    } // Set Multipart as the message's content
    msg.setContent(mp);
    }//End of class
    Madhu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for